getframe produces greater image
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Jan
el 29 de Ag. de 2013
Editada: Jan
el 29 de Ag. de 2013
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 comentarios
Jan
el 29 de Ag. de 2013
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.
Más respuestas (2)
Image Analyst
el 29 de Ag. de 2013
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 comentarios
Image Analyst
el 29 de Ag. de 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.
Adrian
el 29 de Ag. de 2013
Editada: Adrian
el 29 de Ag. de 2013
3 comentarios
Jan
el 29 de Ag. de 2013
Editada: Jan
el 29 de Ag. de 2013
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.
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!