getimage problem

조회 수: 3 (최근 30일)
Razvan
Razvan 2011년 9월 3일
Hi, I would like to use getimage or some other function to capture the current figure which has for example an image + a line drawn on top of it. I tried
imshow rice.png
hold on
line([1 256],[1 256]);
hold off
Im = getimage;
but it doesn't capture the line. Please tell me how it the right way to do this.
Thanks. Razvan

채택된 답변

Walter Roberson
Walter Roberson 2011년 9월 3일
See getframe()
You should also become familiar with saveas() and print(), and if you start doing anything more complex, you should become familiar with the user contribution export_fig
  댓글 수: 3
Razvan
Razvan 2011년 9월 5일
Is it a way to use getframe with a figure which is not visible (after using set(figHandle, 'Visible', 'off')) ? I would like to get the frames of a movie without displaying the movie, and without saving the movie (without |addframe|). Thanks in advance!
Walter Roberson
Walter Roberson 2011년 9월 6일
No, there is no way to getframe() a figure which is not visible.
Capturing frames without displaying them is not easy on Windows, but I seem to recall that someone has a MATLAB File Exchange contribution that helps. And Yair probably has something relevant in his undocumentedmatlab site.
The particular case that you show above, of loading an image and drawing a line parallel to an axis, I would just do all in memory without displaying the images at all: if you have an image, then it is relatively easy to convert the image to truecolor (if it isn't already) and then to set a row or column of the matrix all to a particular value (to create the line.)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by