imshow and Scatter in GUIDE
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everybody, I have lost many hours and I can not find the problem, if someone can help me, I thank you immensely.
I have a program that shows an image at the beginning, then pressing a key, refresh the image (constantly), pressing another key, displays a new image. I'm working with imshow and Scatter, but apparently, they do not relate well, because when I present first the imshow image, the hScatter variants cease to exist and error appears.
this is the initialization:
and this is the Loop:
when i press first "state_3d_view" everything is OK, but if i press "state_3d_view" and then "state_depth_view" and again "state_3d_view" appear the below error!!
i know that the problem is the imshow, because i already commented "set(imshow(depth,[0 outOfRange]),'CData',depth);" and the program and variables works weel.
the error:
Thank you for all the help you can offer.
0 comentarios
Respuestas (2)
OCDER
el 12 de Sept. de 2017
Editada: OCDER
el 14 de Sept. de 2017
Calling imshow can delete the previous axes handle (which is your handles.axes1 and thus your hScatter too).
The following examples shows how imshow deletes handles.
a = axes;
b = imshow(ones(100), 'parent', a); %Show white image
imshow(zeros(100)); %Show black image, BUT deletes previous handles!
a =
handle to deleted Axes
b =
handle to deleted Image
To avoid deleting handles, directly change 'CData' of the image handle.
a = axes;
b = imshow(ones(100), 'parent', a); %Show white image
set(b, 'CData', zeros(100)); %Show black image, but no handles are deleted
So in your code, instead of this:
set(imshow(depth, [0 outOfRange]), 'CData', depth) %Which deletes hScatter when imshow is called.
try this (assuming the image handle is named ImHandle):
set(ImHandle, 'CData', depth) %Doesn't delete any handle
You can also use two separate handles on the GUI, like handles.axes1 and handles.axes2. Store the scatter on handles.axes1 ( using scatter(handles.axes1, ...) ), and image on handles.axes2 ( using imshow(...,'Parent', handles.axes2) ). If you want the image/scatter to be at the same place, use the handles.axesN.Visible = 'on' or 'off' to show or hide the the correct axes in the GUI.
11 comentarios
Márcio Marques
el 12 de Sept. de 2017
2 comentarios
Walter Roberson
el 12 de Sept. de 2017
It makes it more difficult for us to fix the code when you post images of the code instead of the code itself.
Before the loop, initialize a loop counter to 0.
Inside the loop, add 1 to the loop counter.
Replace the call
ter = imshow(depth, [0 OutOfRange]);
set(ter, 'CData', depth)
with
if loop_counter == 1
ter = imshow(depth, [0 OutOfRange]);
else
set(ter, 'CData', depth');
end
Ver también
Categorías
Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!