How to call old GUI in the current working GUI?

I have a current running GUI in which I need to pick an image.
Later, I want the same Image that I picked now to be present in the old GUI that I gonna call.
HERE IS THE CODE OF THE CURRENT RUNNING GUI:
%In the current running GUI I'll pick an image
axes(handles.axes1);
global ImageOriginal
[baseFileName,folder]=uigetfile('*'); % read the input image
ImageOriginal=imread([folder,baseFileName]);
imshow(ImageOriginal);
HERE IS THE PLACE I CALL THE OLD GUI BY THE HELP OF A PUSH BUTTON:
manual_ImageGUI %this is the .m file of my old GUI. I call it in the Current GUI
%But the problem is, when I call this "manual_ImageGUI", again i need to pick an image in it. What i need is, as i already chose the image in the current GUI it should be used in the old GUI too when i call it.
The code in Manual_ImageGUI is :
axes(handles.axes1);
global ImageOriginal
[baseFileName,folder]=uigetfile('*'); % read the input image
im=imread([folder,baseFileName]);
[~,~ , numberOfColorChannels]=size(im);
if numberOfColorChannels > 1
% im = rgb2gray(Iinitial); % converts to gray scale
else
im = Iinitial; % It's already gray.
end
im1=imadjust(im);
imshow(im1);
any help is appreciated... thanks

 Accepted Answer

I'd just create the full filename with fullfile() and then write that out to a mat file that your second GUI can read in.
fullFileName = fullfile(folder, baseFileName);
save('myApp.mat', 'fullFileName');
To recall
storedStructure = load('myApp.mat');
fullFileName = storedStructure.fullFileName;

7 Comments

It is working but I am facing an error when I try to convert it from rgb2gray and imadjust of that fullFileName in the second GUI Here is the CODE in second OLD GUI:
storedStructure = load('myApp.mat');
fullFileName = storedStructure.fullFileName;
im=rgb2gray(fullFileName);
im2=imadjust(im);
imshow(im2);
/////
THE ERROR IS:
Error using rgb2gray>parse_inputs (line 81) MAP must be a m x 3 array.
Error in rgb2gray (line 35) X = parse_inputs(varargin{:});
Error using imadjust
Expected input number 1, I, to be one of these types:
double, uint8, uint16, int16, single
Instead its type was char.
\\\\
So how to get that "fullFileName" as an image FORMAT, so that i can use that to convert to gray scale ..
fullFileName is the string filename. You can store that or the image variable itself. If you store the filename string, you'll have to use imread to read the file into a variable. It sounds like you're rather just store the image array variable itself (though it will make your mat file larger).
fullFileName = fullfile(folder, baseFileName);
rgbImage = imread(fullFileName); % Read it in from disk.
save('myApp.mat', 'rgbImage');
To recall
storedStructure = load('myApp.mat');
rgbImage = storedStructure.rgbImage ;
It is working perfectly. I appreciate your help.
Thank you...
Is there any other way to do this , as in this one it is creating a Microsoft access file ?
Thanks...
I wish to call 2 images into another GUI and i am unable to save 2 images in the same "myApp.mat" file.. how can i do that??
Any suggestion is appreciated....
Why can't you do that? Just call save
save('myapp.mat', 'image1', 'image2');
Obviously, use whatever variable names you have.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!