Saving Figure Data into a Matrix

77 vues (au cours des 30 derniers jours)
Royi Avital
Royi Avital le 4 Juil 2011
Commenté : Yue le 14 Août 2019
Hello.
I'm using 'image()' to display an image. I'm adding some annotations using text.
I'd like to save the final result as matrix (3 Channels of the displayed image width and height). Something like using: OI = get(imageHandler, 'CData'); Yet which includes all the annotations I added.
I know I can use 'saveas' and 'print' yet then the data undergoes some interpolation while I want the data as it is back as a matrix.
Anyone knows how to do it?
Thanks.
  1 commentaire
Zhiyu Xiao
Zhiyu Xiao le 14 Juil 2019
Great question!

Connectez-vous pour commenter.

Réponse acceptée

Gerd
Gerd le 4 Juil 2011
Hi Royi,
you can use the getframe command.
logo = imread('Logo.jpg','jpg');
image(logo);
text(20,30,'Hello')
f=getframe(gcf)
new=f.cdata
imwrite(new,'new.jpg','JPEG')
Gerd
  3 commentaires
Yue
Yue le 14 Août 2019
I met the same question.Have you solved this problem? Looking forward to your answer.
Yue
Yue le 14 Août 2019
I solved this problem just now.
You can try gca command.It returns the current figure or image.
Example:
Frame = getframe(gca);
FrameData = Frame.cdata;
imshow(FrameData)
imwrite(FrameData,'teat.png','PNG');

Connectez-vous pour commenter.

Plus de réponses (1)

Leslie Solorzano
Leslie Solorzano le 16 Déc 2016
https://se.mathworks.com/help/matlab/ref/frame2im.html

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by