help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Base64 String to Image Matrix


From: alex jones
Subject: Base64 String to Image Matrix
Date: Mon, 5 Sep 2016 13:15:36 -0700 (PDT)

I have buit a front end web app that outputs 28x28 pixel RGB images (.png) in
this base64 format (below is an image of the number 9 - can view image here:
http://codebeautify.org/base64-to-image-converter): 

"iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAABkElEQVRIS+2WO46CUBiFDytQFmDUHcAK1B1gRSmlFWpnp5ZWauisdAVCQa3uQFfgawO6gpmcm1yjJnKv4kwmE/6EEGLg4zx+ogHgC784RgZMcrtUKqFYLOJwOGC/32sF85al+Xwei8UC1WpVQM7nszjbtq0EvwRst9uoVCoCROh8PsdsNoPrumg2mwiCAL7vJyrVBo7HY7RaLfGw7XYLwlerlbg+Ho8oFAoYDofodrvpgcxqt9shiiI4jnP3QEKpWlq62WzSA2lbo9FAuVy+y6jf76PX6+F0OgmFhkHDkkfLUpaCSm7VyZdgQ5nn4+/PsEogC7JcLjEYDEBFHILZUlo8nU4RxzE6nQ6Ys2q0gZPJRBSFapjn5XKBZVnwPA+j0Qi1Wu1aoiSoEkgAlzqXy6Ferwt1zFMCZI6maV73MRWQN99Ceb1er69LL4E6heG9SoXybZmlzJCF4cH5MeAzmyTwcWXebqmqdRL4sdJkwMzSxw5o76FqLf5vS/kFCsNQfMh1/kiltlS1px/P8M8DvwGMoe4Br01sxgAAAABJRU5ErkJggg=="

I would like to convert this to a 28x28x3 image matrix in Octave just as the
imread function does. Here is what works given the above string stored in
variable imageBase64.

raw = base64decode(imageBase64);
fid = fopen('buffer.png', 'wb');
fwrite(fid, raw, 'uint8');
fclose(fid);
I = imread('buffer.png');

Though this outputs an I matrix of 28x28x3 dimension, for the application
that I am building I cannot be saving to file and reading the file
afterwards. I know the imread function only takes a file path as an input.
Is there any way to go directly from the base64 string to the I matrix
without writing/reading to file in Octave.

Would really appreciate your help.




--
View this message in context: 
http://octave.1599824.n4.nabble.com/Base64-String-to-Image-Matrix-tp4679632.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]