I want to get the image I got in a function in another function
Show older comments
this is the function I used to get the image
function selectImage_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile({'*.jpg';'*.bmp';'*.png''*.jpeg'},'File Selector');
handles.myImage = strcat(pathname, filename);
axes(handles.imageAxes2);
imshow(handles.myImage)
% save the updated handles object
clear axes scale
axis off
guidata(hObject,handles);
and I'm trying to use the same image in another function
function classifyImage_Callback(hObject, eventdata, handles)
net = alexnet;
image = handles.myImage;
image = imresize(image,[227 227]);
label = classify(net,image);
set(handles.imageType, 'String' , label)

%
2 Comments
kamrul islam sharek
on 22 Sep 2019
I = imread('grey.jpg');
Points = detectSURFFeatures(I );
imshow(I);
hold on;
plot(Points.selectStrongest(10));
problem isError using
detectSURFFeatures>checkImage (line 128)
Input image must be a 2-D grayscale
image. You can use RGB2GRAY to convert
your image to a 2-D grayscale image.
Error in detectSURFFeatures (line 81)
checkImage(I);
Error in Object (line 2)
Points = detectSURFFeatures(I);
>> Object
Error: File: Object.m Line: 2 Column: 31
Invalid expression. Check for missing
multiplication operator, missing or
unbalanced delimiters, or other syntax
error. To construct matrices, use
brackets instead of parentheses.
Image Analyst
on 22 Sep 2019
Edited: Image Analyst
on 22 Sep 2019
Did you use rgb2gray() like it told you to? If not, why not?
rgbImage = imread('grey.jpg');
if ndims(rgbImage) > 1
% Need to convert to gray scale.
grayImage = rgb2gray(rgbImage);
else
grayImage = rgbImage; % It's already gray scale.
end
Points = detectSURFFeatures(grayImage);
Accepted Answer
More Answers (1)
Image Analyst
on 9 Jun 2018
This is wrong:
handles.myImage = strcat(pathname, filename);
You're just storing the filename string, not the actual image.
What you need to do is to call imread() with that filename string to get the actual image:
fullFileName = fullfile(pathname, filename);
handles.myImage = imread(fullFileName);
1 Comment
Mohamed Amine Habch
on 11 Jun 2018
Categories
Find more on Convert Image Type 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!