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

조회 수: 2 (최근 30일)
Rhesezia Intan Tamarena
Rhesezia Intan Tamarena 2019년 11월 26일
댓글: Walter Roberson 2019년 11월 26일
% --- 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
Walter Roberson
Walter Roberson 2019년 11월 26일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by