how to use image as global in push button(GUI) and a file in which all calculation applied on that image??
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
wasif ishaq
il 27 Gen 2015
Commentato: Image Analyst
il 28 Gen 2015
i made gui(push button),which consist of load image,
i declare image as global in callback, now a file.m which consist of all calculation applied on image, image is loaded perfectly,
but i want to know how can i access that image which i have loaded in push button,want to access in file that included all calculations.????????
although, i put global in image discription in callback...
i placed global both side in callback and file ,but not working.
remember i am workin on image ,not a varible.
Risposta accettata
Image Analyst
il 27 Gen 2015
Let's say you read your image into a variable called "rgbImage". So for that GUI pushbutton function and any other functions that need to access that variable, you just put this line as one of the first in the function:
global rgbImage;
Here are some alternate methods: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
2 Commenti
Image Analyst
il 28 Gen 2015
Dont' call imread(im) - imread needs a filename, not an image as an input argument. Anyway you already called it so there is no need to call it again. Don't use size like that, do it this way
[rows, columns, numberOfColorChannels) = size(im);
Anyway, you never use the number of rows and columns in that function so why get them?
Also, sprint() is not a function - it's sprintf().
Do this to read in the file instead of what you did:
% Have user browse for a file, from a specified "starting folder."
% For convenience in browsing, set a starting folder from which to browse.
startingFolder = 'C:\Program Files\MATLAB';
if ~exist(startingFolder, 'dir')
% If that folder doesn't exist, just start in the current folder.
startingFolder = pwd;
end
% Get the name of the file that the user wants to use.
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
im = imread(fullFileName);
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Scope Variables and Generate Names in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!