error using rgb2gray
Mostra commenti meno recenti
I've made GUI with GUIDE which makes RGB image into binary image. Before I change the RGB image into binary image, I read the image from another axes not from folder.
%read multiple image at once and showed it in multiple axes
[files,folder,FilterIndex] = uigetfile('*.jpg*','MultiSelect','on');
handles.img=cell(1,numel(files));
for ifile = 1:numel(files)
filename=fullfile(folder,files{ifile});
img=imread(filename);
ax = findall(gcf,'type','axes','tag',sprintf('axes%d',ifile));
imshow(img,'Parent',ax);
handles.img{ifile} = img;
end
guidata(hObject,handles);
%change RGB image in axes1 into binary image
proses=guidata(gcbo);
D=get(proses.citraasli,'Userdata');
abu=rgb2gray(D);
cb=imclearborder(abu);
thresh=graythresh(cb);
b=im2bw(cb,thresh);
bw=bwareaopen(b,60);
bwfill=imfill(bw,'holes');
[c,num]=bwlabel(bwfill,8);
for i=1:1:num
axesName=sprintf('axes%d',i);
ax=handles.(axesName);
imshow((c==i),'Parent',ax);
end
guidata(hObject,handles);
This command works properly in another GUI program, but it gives that following 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 ==> guikedelaizulfa>ekstrakfitur_Callback at 1127
abu=rgb2gray(D);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> guikedelaizulfa at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)guikedelaizulfa('ekstrakfitur_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
>>
I've checked the image is RGB image, and i can't find the problem to fix it. If somebody knows how to fix it, please help me! Thank you!
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Image Arithmetic in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!