i make a function in which i apply contouring on image and can not access in other function as i set it as global?what should i do?

i make a function in which i apply contouring on image and set it as global .now i want to use this global variable in other function.i use this variable to show the image but it show nothing.my code is
function pushbutton5_Callback(hObject, eventdata, handles)
global scx
imshow(scx)
function pushbutton6_Callback(hObject, eventdata, handles)
global scx
global a
gd = imread(a);
%imshow(sx)
sf = rgb2gray(gd);
scx = imcontour(sf , 10);
it show just blank popup screen and does not show the image that is save in scx variable. waiting for your help.

 Risposta accettata

The first output of imcontour is a contour matrix, which is a numeric matrix made in a special form. You cannot display the contour plot by using imshow on the contour matrix.
No documented routine is provided to draw a contour matrix.
No documented routine is provided to write a contour plot directly into an image without displaying the contour plot first.
You should consider recording the second output of imcontour and setting the Visible property of it off until you want to see it and then set the Visible property to on

9 Commenti

and what should i do if i want to perform some operation on the contoured image?how i can store the contoured image in a variable? kindly help me please image analyst and walter roberson.
[scx, ch] = imcontour(sf , 10);
set(ch, 'Visible', 'off')
and somehow record the handle and when you want to see it,
set(ch, 'Visible', 'on')
If you want to perform an operation on the contoured image then you will either need to create a routine to draw contours given a contour matrix, or you will need to use one of the methods to capture drawn graphics, such as getframe() or saveas()
thanks a lot. walter roberson will you please elaborate the getframe and saveas? how i can use it for saving a contoured image?
i use saveas(gcf , 'img.png') it save the whole interface that i created. i just want to get the image that is contoured.is there any method? my img is
[scx, ch] = imcontour(sf , 10);
ax = ancestor(ch, 'axes');
set(ax, 'visible', 'off')
frame = getframe(ax);
contour_image = frame.cdata;
figure();image(contour_image); %so you can see it worked
i am very thankful to you Walter roberson. you did not know how much you helped me. thanks a lot :)

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by