how to pass an image from a push button to function ?
Show older comments
I have created two push buttons to browse images for the original and target images and these images are taken for the further process.
function pushbutton1_Callback(hObject, eventdata, handles)
[original pathname1] = uigetfile({'*.jpg';'*.bmp'},'File Selector');
handles.originalImage = strcat(pathname1, original);
guidata(hObject,handles);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
[target pathname2] = uigetfile({'*.jpg';'*.bmp'},'File Selector');
handles.targetImage = strcat(pathname2, target);
guidata(hObject,handles);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
proceed=msgbox('operation completed');
if isfield(handles,'originalImage')
original=msgbox('original image uploaded successfully');
im1=handles.originalImage
end
if isfield(handles,'targetImage')
target=msgbox('target image uploaded successfully');
im2=handles.targetImage
end
Mosaic=ritfn(im1,im2);
Another function
function [Mosaic] = ritfn(im1,im2)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
%Prepare Workspace
clear;clc;close all
%%Read Secret and Target images;
S=imread(im1); %Secret Image
T=imread(im2); %Target Image
M=256;
N=192;
S=imresize(S,[M,N]);
T=imresize(T,[M,N]);
end
But the problem is
Reference to a cleared variable im1.
Error in ritfn (line 7)
S=imread(im1); %Secret Image
Error in rdhgui>pushbutton3_Callback (line 101)
Mosaic=ritfn(im1,im2);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in rdhgui (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)rdhgui('pushbutton3_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Accepted Answer
More Answers (0)
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!