필터 지우기
필터 지우기

getframe + frame2im + imwrite - Save figure

조회 수: 15 (최근 30일)
Gennaro Arguzzi
Gennaro Arguzzi 2017년 6월 26일
댓글: Walter Roberson 2017년 6월 27일
Hi everyone. I'd like to save a figure using statements getframe+frame2im+imwrite (without print statement). Is it possible to do it? I wrote the following code:
close all
clear all
t=[0:0.1:10];
x=t;
plot(t,x)
f=getframe(gcf);
[X,Map]=frame2im(f);
a=imwrite(X,'Figura 1.jpg')
but there is the error:
Error using imwrite Too many output arguments.
Error in Untitled2 (line 8) a=imwrite(X,'Figura 1.jpg')
Thank you very much.

답변 (2개)

Walter Roberson
Walter Roberson 2017년 6월 26일
imwrite() has no outputs. It just creates the file. If for some reason you want to load the content of the file back in to compare to the data in X that you wrote out, then use imread() on the file.
Note: .jpg files will rarely compare exactly equal to the original data, because JPEG loses information as it compresses data.
  댓글 수: 2
Gennaro Arguzzi
Gennaro Arguzzi 2017년 6월 26일
Hi @Walter Roberson, maybe before I need to convert figure in frame, then I assign an index using read(frame,1) and at the end I use imwrite? The problem is how can I convert figure in frame? Thank you.
Walter Roberson
Walter Roberson 2017년 6월 27일
imwrite(f.cdata, 'Figura 1.jpg')

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


Image Analyst
Image Analyst 2017년 6월 27일
  댓글 수: 1
Gennaro Arguzzi
Gennaro Arguzzi 2017년 6월 27일
Hi @Image Analyst, I'm doing that because I want to learn all ways to do the same thing in MATLAB.

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

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by