GUI ...I have called one image on axes1 with the help of one push button..now how to call first image on axes2 with the help of second push button..??

I have called one image on axes1 with the help of one push button.. with the help of second push button again i call image, conversion apply on it.. but when i am click second push button then again all image open steps are doing.. directly push button not taking reference of axes1 image for axes2.. what i do??

4 Comments

What happens when you press the second pushbutton? Didn't understand.
What do you mean with "all image open steps are doing" ?
first i called image on axes1 with first push button:
function open_Callback(hObject, eventdata, handles) % hObject handle to open (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile('*.m', 'Pick a MATLAB code file'); if isequal(filename,0) isequal(pathname,0) disp('User pressed cancel') else a = imread(filename); axes(handles.axes1); imshow(a); title('original image');
end
now with the help of second push button conversion take place on axes2 image but i cant directly called first axes1 image on second axes2..
function conversion_Callback(hObject, eventdata, handles)
% hObject handle to conversion (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile('*.m', 'Pick a MATLAB code file');
if isequal(filename,0) || isequal(pathname,0)
disp('User pressed cancel')
else
I = imread(filename); image_gray=rgb2gray(I);
axes(handles.axes2);
imshow(image_gray);
ginv = imcomplement (image_gray);
adahist = adapthisteq(ginv);
L = medfilt2(adahist,[3 3]);
D = medfilt2(L,[3 3]);
axes(handles.axes3);
imshow(D);
title('filtered image');
As Joakim I didn't quite understand, but you might want to use the 'parent' property of imshow to display the right image on the right axes:
eg:
imshow(image_gray,'Parent',handles.axes2);
imshow(D,'Parent',handles.axes3);
So is your problem that only the first image (image_gray) is displayed in the first axes?
it's right but i think get function is used for calling one image from axes1 to axes2

Sign in to comment.

 Accepted Answer

Kanu - if you want to avoid opening the file browser a second time and take the image directly from the first axes, then what you can do is save the image data to the handles structure using guidata. Modify the callback for your first push button as
function open_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile('*.m', 'Pick a MATLAB code file');
if isequal(filename,0)
disp('User pressed cancel')
else
a = imread(filename);
axes(handles.axes1);
imshow(a);
title('original image');
% now update the handles structure with the image
handles.imgData = a;
% save the handles data
guidata(hObject,handles);
end
Now, the image data is available wherever your code has access to the handles structure. So in your second button callback, do
function conversion_Callback(hObject, eventdata, handles)
% check to make sure that the image data exists in handles
if isfield(handles,'imgData')
% grab the image data from handles
I = handles.imgData;
image_gray=rgb2gray(I);
axes(handles.axes2);
imshow(image_gray);
ginv = imcomplement (image_gray);
adahist = adapthisteq(ginv);
L = medfilt2(adahist,[3 3]);
D = medfilt2(L,[3 3]);
axes(handles.axes3);
imshow(D);
title('filtered image');
end
So the above is similar to your code with the exception of the file browsing being replaced with the access to the image data from handles.
Try the above and see what happens!

2 Comments

hey Geoff Hayes, thanks... result come correct..now i directly convert my image in other filters..no need to call image again and again..
even I was stuck in the same place, thank you Mr. Hayes

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Asked:

on 12 Aug 2014

Commented:

on 13 May 2015

Community Treasure Hunt

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

Start Hunting!