Saving Figure Data into a Matrix

조회 수: 49 (최근 30일)
Royi Avital
Royi Avital 2011년 7월 4일
댓글: Yue 2019년 8월 14일
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.

채택된 답변

Gerd
Gerd 2011년 7월 4일
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
Yue
Yue 2019년 8월 14일
I met the same question.Have you solved this problem? Looking forward to your answer.
Yue
Yue 2019년 8월 14일
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');

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Leslie Solorzano
Leslie Solorzano 2016년 12월 16일
https://se.mathworks.com/help/matlab/ref/frame2im.html

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by