Loading either one or multiple images Matlab GUI
up vote
1
down vote
favorite
I want to load multiple images in Matlab GUI. Algorithm below:
% --- Executes on button press in pushbutton1.
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)
[filename path] = uigetfile('*.jpg','*.png','Chose files to
load','MultiSelect','on');
if isequal(filename,0) || isequal(path,0)
return
end
if iscell(filename)
img = cell(size(filename));
for ii = 1:numel(filename)
img{ii} = imread(fullfile(path,filename{ii}));
end
else
img{1} = imread(fullfile(path,filename));
end
filename = strcat(path,filename);
fullpathname = strcat(path, filename);
set(handles.edit1,'String', fullpathname);
fileID = fopen(strcat(path, filename), 'r');
I also need the directory of an image or images to bee seen text box, but it gives me subsequent error:
Error using imread>parse_inputs (line 457)
The file name or URL argument must be a string.
Error in imread (line 316)
[filename, fmt_s, extraArgs] = parse_inputs(varargin{:});
Error in untitled>pushbutton1_Callback (line 112)
im = rgb2gray(imread(filename));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in untitled (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)
untitled('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Could you please give me a hint, what and how I can customize the algorithm to make it functional?
matlab matlab-guide
add a comment |
up vote
1
down vote
favorite
I want to load multiple images in Matlab GUI. Algorithm below:
% --- Executes on button press in pushbutton1.
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)
[filename path] = uigetfile('*.jpg','*.png','Chose files to
load','MultiSelect','on');
if isequal(filename,0) || isequal(path,0)
return
end
if iscell(filename)
img = cell(size(filename));
for ii = 1:numel(filename)
img{ii} = imread(fullfile(path,filename{ii}));
end
else
img{1} = imread(fullfile(path,filename));
end
filename = strcat(path,filename);
fullpathname = strcat(path, filename);
set(handles.edit1,'String', fullpathname);
fileID = fopen(strcat(path, filename), 'r');
I also need the directory of an image or images to bee seen text box, but it gives me subsequent error:
Error using imread>parse_inputs (line 457)
The file name or URL argument must be a string.
Error in imread (line 316)
[filename, fmt_s, extraArgs] = parse_inputs(varargin{:});
Error in untitled>pushbutton1_Callback (line 112)
im = rgb2gray(imread(filename));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in untitled (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)
untitled('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Could you please give me a hint, what and how I can customize the algorithm to make it functional?
matlab matlab-guide
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I want to load multiple images in Matlab GUI. Algorithm below:
% --- Executes on button press in pushbutton1.
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)
[filename path] = uigetfile('*.jpg','*.png','Chose files to
load','MultiSelect','on');
if isequal(filename,0) || isequal(path,0)
return
end
if iscell(filename)
img = cell(size(filename));
for ii = 1:numel(filename)
img{ii} = imread(fullfile(path,filename{ii}));
end
else
img{1} = imread(fullfile(path,filename));
end
filename = strcat(path,filename);
fullpathname = strcat(path, filename);
set(handles.edit1,'String', fullpathname);
fileID = fopen(strcat(path, filename), 'r');
I also need the directory of an image or images to bee seen text box, but it gives me subsequent error:
Error using imread>parse_inputs (line 457)
The file name or URL argument must be a string.
Error in imread (line 316)
[filename, fmt_s, extraArgs] = parse_inputs(varargin{:});
Error in untitled>pushbutton1_Callback (line 112)
im = rgb2gray(imread(filename));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in untitled (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)
untitled('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Could you please give me a hint, what and how I can customize the algorithm to make it functional?
matlab matlab-guide
I want to load multiple images in Matlab GUI. Algorithm below:
% --- Executes on button press in pushbutton1.
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)
[filename path] = uigetfile('*.jpg','*.png','Chose files to
load','MultiSelect','on');
if isequal(filename,0) || isequal(path,0)
return
end
if iscell(filename)
img = cell(size(filename));
for ii = 1:numel(filename)
img{ii} = imread(fullfile(path,filename{ii}));
end
else
img{1} = imread(fullfile(path,filename));
end
filename = strcat(path,filename);
fullpathname = strcat(path, filename);
set(handles.edit1,'String', fullpathname);
fileID = fopen(strcat(path, filename), 'r');
I also need the directory of an image or images to bee seen text box, but it gives me subsequent error:
Error using imread>parse_inputs (line 457)
The file name or URL argument must be a string.
Error in imread (line 316)
[filename, fmt_s, extraArgs] = parse_inputs(varargin{:});
Error in untitled>pushbutton1_Callback (line 112)
im = rgb2gray(imread(filename));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in untitled (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)
untitled('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Could you please give me a hint, what and how I can customize the algorithm to make it functional?
matlab matlab-guide
matlab matlab-guide
asked Nov 7 at 13:21
Franta Mráz
63
63
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
One reason for the code to fail is that once you merge the filename
and the path
you miss a /
(or depending on which OS you are working). Therefore you should use
fullfile(path,filename)
instead of strcat(path,filename)
.
Works. Thank you!
– Franta Mráz
Nov 7 at 14:23
I'm happy to hear that @FrantaMráz!
– Pablo Jeken
Nov 7 at 15:51
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
One reason for the code to fail is that once you merge the filename
and the path
you miss a /
(or depending on which OS you are working). Therefore you should use
fullfile(path,filename)
instead of strcat(path,filename)
.
Works. Thank you!
– Franta Mráz
Nov 7 at 14:23
I'm happy to hear that @FrantaMráz!
– Pablo Jeken
Nov 7 at 15:51
add a comment |
up vote
1
down vote
accepted
One reason for the code to fail is that once you merge the filename
and the path
you miss a /
(or depending on which OS you are working). Therefore you should use
fullfile(path,filename)
instead of strcat(path,filename)
.
Works. Thank you!
– Franta Mráz
Nov 7 at 14:23
I'm happy to hear that @FrantaMráz!
– Pablo Jeken
Nov 7 at 15:51
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
One reason for the code to fail is that once you merge the filename
and the path
you miss a /
(or depending on which OS you are working). Therefore you should use
fullfile(path,filename)
instead of strcat(path,filename)
.
One reason for the code to fail is that once you merge the filename
and the path
you miss a /
(or depending on which OS you are working). Therefore you should use
fullfile(path,filename)
instead of strcat(path,filename)
.
edited Nov 7 at 14:06
answered Nov 7 at 13:47
Pablo Jeken
429114
429114
Works. Thank you!
– Franta Mráz
Nov 7 at 14:23
I'm happy to hear that @FrantaMráz!
– Pablo Jeken
Nov 7 at 15:51
add a comment |
Works. Thank you!
– Franta Mráz
Nov 7 at 14:23
I'm happy to hear that @FrantaMráz!
– Pablo Jeken
Nov 7 at 15:51
Works. Thank you!
– Franta Mráz
Nov 7 at 14:23
Works. Thank you!
– Franta Mráz
Nov 7 at 14:23
I'm happy to hear that @FrantaMráz!
– Pablo Jeken
Nov 7 at 15:51
I'm happy to hear that @FrantaMráz!
– Pablo Jeken
Nov 7 at 15:51
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53190322%2floading-either-one-or-multiple-images-matlab-gui%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown