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)
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
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;
  2 Commenti
wasif ishaq
wasif ishaq il 27 Gen 2015
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 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);

Accedi per commentare.

Più risposte (0)

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!

Translated by