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.
  1 件のコメント
wasif ishaq
wasif ishaq 2015 年 1 月 27 日
ERROR is The filename or url argument must be a string.
how can i convert image in string?

サインインしてコメントする。

採用された回答

Image Analyst
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;
  2 件のコメント
wasif ishaq
wasif ishaq 2015 年 1 月 27 日
i send u code of push button
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im im2
[path,user_cance]=imgetfile();
if user_cance
msgbox(sprint('Error'),'Error','Error');
return
end
im=imread(path);
im=im2double(im);
im2=im;
axes(handles.axes1);
imshow(im);
*now i want to use image in this file *
global im
imread(im);
[r c]=size(im);
LBP=zeros(256,1);
freq=zeros(1,256);
%h=zeros(255,1);
offset= 3;
%incompllete code here,but accurate...
  • i just want that when i push button then image is automatically call in this file....????????????????? *
Image Analyst
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 ExchangeScope Variables and Generate Names についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by