I'm confused about the error. the result of its feature extraction cannot appear in uitable1, every time i run, get out matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)UASPCD('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

10 Kommentare

Image Analyst
Image Analyst am 11 Nov. 2021
What line number is the error on?
I can't run an image. I can only run code. Attach the .fig and .m file, or at least give us the code for the pushbutton2 callback because no one is going to type all that stuff in just to help you. Make it easy for us to help you, not hard.
Erika Maulidiya
Erika Maulidiya am 11 Nov. 2021
sorry for my negligence in making a question that may be incomplete
Erika Maulidiya
Erika Maulidiya am 11 Nov. 2021
okay, I will explain my problem, I use GLCM feature extraction in matlab using 4 features, namely contrast, correlation, energy and homogeneity. My progress has been to input the image and convert it to grayscale. but when I press the "GLCM" button there must be an error, the data doesn't want to come out in the table
Erika Maulidiya
Erika Maulidiya am 11 Nov. 2021
Erika Maulidiya
Erika Maulidiya am 11 Nov. 2021
Bearbeitet: Image Analyst am 11 Nov. 2021
Here is the code in pushbutton2 callback.
img = handles.img;
img_gray = rgb2gray(img);
axes(handles.axes2)
imshow(img_gray)
title('Grayscale Image')
pixel_dist = str2double(get(handles.edit2,'String'));
GLCM = graycomtrix(img_gray,'Offset',[0 pixel_dist;...
-pixel pixel; -pixel 0; -pixel_dist pixel_dist]);
stats = graycoprops(GLCM,{'Contrast','Correlation','Energy','Homogeneity'});
Contrast = stats.Contrast;
Correlation = stats.Correlation;
Energy = stats.Energy;
Homogeneity = stats.Homogeneity;
data = get(handles.uitbale1,'Data');
data{1,1} = num2str(Contrast(1));
data{1,2} = num2str(Contrast(2));
data{1,3} = num2str(Contrast(3));
data{1,4} = num2str(Contrast(4));
data{1,5} = num2str(mean(Contrast));
data{2,1} = num2str(Correlation(1));
data{2,2} = num2str(Correlation(2));
data{2,3} = num2str(Correlation(3));
data{2,4} = num2str(Correlation(4));
data{2,5} = num2str(mean(Correlation));
data{3,1} = num2str(Energy(1));
data{3,2} = num2str(Energy(2));
data{3,3} = num2str(Energy(3));
data{3,4} = num2str(Energy(4));
data{3,5} = num2str(mean(Energy));
data{4,1} = num2str(Homogeneity(1));
data{4,2} = num2str(Homogeneity(2));
data{4,3} = num2str(Homogeneity(3));
data{4,4} = num2str(Homogeneity(4));
data{4,5} = num2str(mean(Homogeneity));
set(handles.uitable1,'Data',data)
but I still get an error.
Image Analyst
Image Analyst am 11 Nov. 2021
What is the value of pixel_dist and pixel?
Do you have the code for your "graycomtrix" function? This is not a built-in function. Or did you just misspell graycomatrix()?
Erika Maulidiya
Erika Maulidiya am 12 Nov. 2021
value of pixel_dist and pixel is 1
for my code graycomtirx, i copied some tutorials on youtube
Image Analyst
Image Analyst am 12 Nov. 2021
If you don't want to use the built-in graycomatrix() then attach your custom "graycomtirx" or "graycomtrix" or whatever you called or spelled it (or misspelled it). I can't run it unless you upload your custom code for that function. Is there any reason why you're using some YouTube version of graycomatrix() rather than the built-in version?
Erika Maulidiya
Erika Maulidiya am 12 Nov. 2021
actually I don't understand and don't know whether graycomtrix is ​​the default code or what, and actually it's finished, but I want to add features, have you ever used features other than the ones I used? like entropy? or ASM or IDM? so where i can add this features in my code right know?
Image Analyst
Image Analyst am 17 Nov. 2021
I've used all kinds of features. There are a bazillion things you could potentially measure. You need to understand your image to know what kinds of things will be worth measuring.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

yanqi liu
yanqi liu am 12 Nov. 2021
sir, may be some code write confuse,please check the follow
clear all; clc; close all;
img = imread('football.jpg');
img_gray = rgb2gray(img);
figure;
imshow(img_gray)
title('Grayscale Image')
pixel_dist = 2;
GLCM = graycomatrix(img_gray,'Offset',[0 pixel_dist;...
-pixel_dist pixel_dist; -pixel_dist 0; -pixel_dist pixel_dist]);
stats = graycoprops(GLCM,{'Contrast','Correlation','Energy','Homogeneity'});
Contrast = stats.Contrast;
Correlation = stats.Correlation;
Energy = stats.Energy;
Homogeneity = stats.Homogeneity;
data = [];
data{1,1} = num2str(Contrast(1));
data{1,2} = num2str(Contrast(2));
data{1,3} = num2str(Contrast(3));
data{1,4} = num2str(Contrast(4));
data{1,5} = num2str(mean(Contrast));
data{2,1} = num2str(Correlation(1));
data{2,2} = num2str(Correlation(2));
data{2,3} = num2str(Correlation(3));
data{2,4} = num2str(Correlation(4));
data{2,5} = num2str(mean(Correlation));
data{3,1} = num2str(Energy(1));
data{3,2} = num2str(Energy(2));
data{3,3} = num2str(Energy(3));
data{3,4} = num2str(Energy(4));
data{3,5} = num2str(mean(Energy));
data{4,1} = num2str(Homogeneity(1));
data{4,2} = num2str(Homogeneity(2));
data{4,3} = num2str(Homogeneity(3));
data{4,4} = num2str(Homogeneity(4));
data{4,5} = num2str(mean(Homogeneity));
% set(handles.uitable1,'Data',data)
data
data = 4×5 cell array
{'0.3785' } {'0.42167'} {'0.41022'} {'0.42167'} {'0.40802'} {'0.86492'} {'0.8505' } {'0.85408'} {'0.8505' } {'0.855' } {'0.21656'} {'0.20997'} {'0.20975'} {'0.20997'} {'0.21156'} {'0.86514'} {'0.85481'} {'0.85348'} {'0.85481'} {'0.85706'}

3 Kommentare

Erika Maulidiya
Erika Maulidiya am 12 Nov. 2021
omg thank u so much :D
Erika Maulidiya
Erika Maulidiya am 12 Nov. 2021
I want to add features, have you ever used features other than the ones I used? like entropy? or ASM or IDM? so where i can add this features in my code right know?
yanqi liu
yanqi liu am 13 Nov. 2021
yes,sir,the function graycomtrix may be a self define function,may be upload it to analysis

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by