How to fix this error?? --> Error using ==> or Matrix dimensions must agree.

2 vues (au cours des 30 derniers jours)
Rhesezia Intan Tamarena
Rhesezia Intan Tamarena le 26 Nov 2019
Commenté : Walter Roberson le 26 Nov 2019
% --- 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)
[namafile, formatfile] = uigetfile({'*.png','*.jpg'}, 'membuka gambar'); %memilih gambar
image = imread([formatfile, namafile]); %membaca gambar
guidata(hObject, handles)
axes(handles.axes1); %memilih axes1 sebagai letak gambar yang dimunculkan
imshow(rgb2gray(image));%memunculkan gambar
image = GLCM(image)
tab(:,1)= [image(1,1) image(1,2) image(1,3) image(1,4) ]';
tab(:,2)= [image(1,5) image(1,6) image(1,7) image(1,8) ]';
tab(:,3)= [image(1,9) image(1,10) image(1,11) image(1,12) ]';
tab(:,4)= [image(1,13) image(1,14) image(1,15) image(1,16) ]';
tab(:,5)= [image(1,17) image(1,18) image(1,19) image(1,20) ]';
set(handles.uitable1, 'Data', tab);
training1 = xlsread('hasilsemua','Training1');
group = training1(:,23);
training = [training1(:,1) training1(:,2) training1(:,3) training1(:,4) training1(:,5) training1(:,6) training1(:,7) training1(:,8) training1(:,9) training1(:,10) training1(:,11) training1(:,12) training1(:,13) training1(:,14) training1(:,15) training1(:,16) training1(:,17) training1(:,18) training1(:,19) training1(:,20)];
hasil1=knnclassify(image,training,group);
if hasil1==1
x='Kelas 3';
elseif hasil1==2
x='Kelas 4';
end
set(handles.edit2,'string',x);
pixel_dist = str2double(get(handles.edit1,'string'));
[glcm,SI] = graycomatrix(image,'Offset',[0 pixel_distance; -pixel_distance pixeldistance; -pixel_distance 0; -pixel_distance -pixel_distance]);
i will put pixel distance function in GLCM program, but i have some problem :
I hope i can fix this problem as soon as possible, plese help me, thanks.
??? Error using ==> or
Matrix dimensions must agree.
Error in ==> graycomatrix>computeGLCM at 233
bad = isnan(v1) | isnan(v2);
Error in ==> graycomatrix at 196
GLCMS(:,:,k) = computeGLCM(r,c,Offset(k,:),SI,NL);
Error in ==> cobaGUI>pushbutton1_Callback at 108
[glcm,SI] = graycomatrix(image,'Offset',offsets);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> cobaGUI at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)cobaGUI('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
  1 commentaire
Walter Roberson
Walter Roberson le 26 Nov 2019
image = GLCM(image)
GLCM is not a Mathworks supplied routine, and we do not know how it will handle when you pass in RGB images. We know from the line before,
imshow(rgb2gray(image));%memunculkan gambar
that you are expecting image to be RGB.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by