getframe produces greater image
Show older comments
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.
Accepted Answer
More Answers (2)
Image Analyst
on 29 Aug 2013
0 votes
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 Comments
Adrian
on 29 Aug 2013
Image Analyst
on 29 Aug 2013
Did you try various axis options like axis off, axis image, etc.?
Image Analyst
on 29 Aug 2013
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."
I still do not get the problem. What exactly does "I have a while loop showing a movie on an axes" mean? If you show the move image by image, the image data are available directly. Then using GETFRAME is an unnecessary indirection. Please show us the code.
Adrian
on 29 Aug 2013
Jan
on 29 Aug 2013
See my answer.
Image Analyst
on 29 Aug 2013
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 Comments
Image Analyst
on 29 Aug 2013
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.
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!