how to use image as global in push button(GUI) and a file in which all calculation applied on that image??
5 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
Image Analyst
2015-1-27
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 个评论
Image Analyst
2015-1-28
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);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scope Variables and Generate Names 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!