I want to convert a matlab figure into a binary column vector as would be produced by fread
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have generated a plot in matlab:
fig = surf(peaks)
I need it to be in the form of a column vector in order to be used as input for the following base64 encoding function:
str64 = matlab.net.base64encode(im_uint8);
The way I am currently doing it is by first saving the plot as png and then reading the binary file as follow:
saveas(fig,'plot1.png')
fid = fopen( 'plot1.png', 'r' );
im = fread(fid);
im_uint8 = uint8(im);
fclose(fid);
Then I can easily call the encoding function. The thing is this saving/reading steps take quite sometimes and I would like to avoid them. I have tried without sucess so far to go from the variable fig above to the variable im.
Is there anyone with a solution for this?
PS: I do not have the image processing toolbox.
0 commentaires
Réponses (1)
Image Analyst
le 3 Mai 2022
Perhaps you want this:
p = uint8(peaks(:)); % p will be a uint8 column vector of your data.
Voir également
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!