From: Dave on 28 Jun 2010 08:23 I need to access a bunch of images from a folder.For this purpose I used GUIDE tool and I got different errors in different situations as below. ==>Trial 1: function pushbutton1_Callback(hObject, eventdata, handles) clc; [filename,pathname] = uigetfile({'*.png';'*.jpg'},'Select Your Images','Multiselect','on'); %imagename = strcat(pathname,filename); msgbox(pathname); flength = length(filename); plength = length(pathname); for pcount=1:plength for flength=1:flength pname = pathname(plength); fname = filename(flength); ifname=strcat(pname,fname); msgbox(ifname); inimage = imread(ifname); figure,imshow(inimage); end end Error I got: ?? Conversion to logical from cell is not possible. Error in ==> imread at 282 if (strfind(filename, '://')) Error in ==> GUIDEMO1>pushbutton1_Callback at 91 inimage = imread(ifname); Error in ==> gui_mainfcn at 96 feval(varargin{:}); Error in ==> GUIDEMO1 at 42 gui_mainfcn(gui_State, varargin{:}); ??? Error while evaluating uicontrol Callback This may be due to the back slash(\) that appears at the end of the path name and at the beginning of the file name .My question is how to remove that back space?? ==>Trial2: I concatenated both filename and pathname into imagename(it is a cell). without any back slash problem,but when I tried to use the function imread(). function pushbutton1_Callback(hObject, eventdata, handles) clc; [filename,pathname] = uigetfile({'*.png';'*.jpg'},'Select Your Images','Multiselect','on'); imagename = strcat(pathname,filename); msgbox(imagename); listlength =length(imagename); %celldisp(imagename); %sizeinstr = num2str(listlength); %msgbox(sizeinstr) %x=iscellstr(imagename) for count=1:listlength location=imagename(1,count); msgbox(location); imageread = imread(location); imshow(imageread); image2=rgb2gray(image1); image3=im2uint8(image1); figure,imshow(image3); cnt = num2str(count); msgbox(cnt) end Error I got(Same as previous one): ??? Conversion to logical from cell is not possible. Error in ==> imread at 282 if (strfind(filename, '://')) Error in ==> GUIDEMO1>pushbutton1_Callback at 105 imageread = imread(location); Error in ==> gui_mainfcn at 96 feval(varargin{:}); Error in ==> GUIDEMO1 at 42 gui_mainfcn(gui_State, varargin{:}); ??? Error while evaluating uicontrol Callback ==>Trial3: Now Iam able to view the images without using imread,rgb2gray,im2uint8 functions by accessing the image as imagename{1,count} for count=1:listlength image=imagename{1,count}; %msgbox(location); imshow(imaged); image2=rgb2gray(image); image3=im2uint8(image2); figure,imshow(image3); cnt = num2str(count); msgbox(cnt) end Error: ??? Error using ==> rgb2gray>parse_inputs at 82 MAP must be a m x 3 array. Error in ==> rgb2gray at 35 X = parse_inputs(varargin{:}); Error in ==> GUIDEMO1>pushbutton1_Callback at 107 image2=rgb2gray(location); Error in ==> gui_mainfcn at 96 feval(varargin{:}); Error in ==> GUIDEMO1 at 42 gui_mainfcn(gui_State, varargin{:}); ??? Error while evaluating uicontrol Callback My query is a bit lengthy please excuse me but, I am at the end of my task.At this point I got the above problem.Could any one help me out. Regards, Dave.
|
Pages: 1 Prev: repeating sequence block HELP Next: Help me by checking this image accessing code using GUI. |