getframe produces greater image
이전 댓글 표시
Hello,
I am using getframe() to read out axes that show an image. For example an 120x90 image. But the image I get from the getframe() function has a size of 121x91. There is a small white border. How can I turn that off? Btw I am showing the image without axis.
채택된 답변
추가 답변 (2개)
Image Analyst
2013년 8월 29일
0 개 추천
Just get the image itself, like what you put into the axes when you called image(), imshow(), or imagesc(). I mean, you have it, since you put it in there, right?
댓글 수: 9
Adrian
2013년 8월 29일
Image Analyst
2013년 8월 29일
Did you try various axis options like axis off, axis image, etc.?
Image Analyst
2013년 8월 29일
I've never tried to grab a screenshot off a video as it's playing "live." Maybe you could use VideoReader to extract a frame at a time and use imshow() to display it then capture the last frame extracted when the user clicks the button. Alternatively, you can use imcrop to cut off the small white border. By the way, I don't know what you mean by "lose the handles."
Adrian
2013년 8월 29일
Jan
2013년 8월 29일
See my answer.
Image Analyst
2013년 8월 29일
You need to call guidata immeidately after you attach/update handles.frame_xy, otherwise anything you attached to handle inside your function with the loop will not be available in it's current/updated form to the function with the button that saves the current image to disk.
댓글 수: 3
Image Analyst
2013년 8월 29일
Yes, that's true - it will be lost unless you take care to retain it. Why do you need Snapshot1 anyway? You can either pass handles back in the output argument list, or call guidata() right after you attach Snapshot1 to handles.
while (time < 1/FrameRate), time = etime(clock, start); end is a brute waste of time. A timer would be smarter and more flexible.
As I have written already: If you want to share the handles struct with other callback, store it by guidata:
handles.count=count;
guidata(hObject, handles);
...
Then you can obtain the current value by:
handles = guidata(hObject);
The problem is that the updated handles struct is contained in the local copy in the workspace of the corresponding function. But each function, here each callback, has its own workspace and changes in one workspace do not propagate magically to others.
Please take the time and follow my suggestion to search in the forum for methods to share variables between callbacks. It has been discussed such often, that it is worth to use the history of this forum instead of asking new questions.
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!