getframe produces greater image
5 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Jan
2013-8-29
编辑:Jan
2013-8-29
I do not understand your explanations. What is "the number of the current frame"? You cannot store a number "in a handle", because a handle is a kind of pointer to a HG object and created by Matlab. You mean a struct called "handle", but this is a confusing formulation. What do you think is stored in handle.frame_xy?
Again, please show us the code. It sounds like you forgot to store the modified handles struct. Then this might help:
function TheButtonCallback(hObject, EventData)
handles = guidata(hObject); % Get handles struct from figure
handles.frame_xy = how ever you obtain it
guidata(hObject, handles); % Store modified struct in the figure
Then the modified handles struct can be obtained by guidata again. If this is your problem, sharing data between callbacks is your main problem, and the extremely confusing decision of TMW to call the struct for storing figure related information "handles". Use the Search field of this forum and look form "share gui" to find many related threads: http://www.mathworks.com/matlabcentral/answers/?term=share+gui
3 个评论
Jan
2013-8-29
These are only parts of the code and if the complete code contains the necessary further commands, everything is fine. But you do not show us the additional lines, such that we must guess, what is missing.
Please post the complete relevant part of the code.
Running a while loop, which does not perform anything, is a waste of time. If actions are triggered by the callback of another button, you can omit the loop completely and insert the action in the callback.
更多回答(2 个)
Image Analyst
2013-8-29
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 个评论
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.
Adrian
2013-8-29
编辑:Adrian
2013-8-29
3 个评论
Jan
2013-8-29
编辑:Jan
2013-8-29
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!