error inundefined function or method 'mtimes' for input arguments of type struct??
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
preeti
am 19 Aug. 2015
Kommentiert: preeti
am 19 Aug. 2015
gui code for browser button:-
[filename pathname]=uigetfile({'*.jpg';'*.bmp'},'File selector');
image=strcat(pathname, filename);
axes(handles.axes1)
imshow(image)
read_query(filename);% function call whose defination is given below
now code for read query:-
function img=read_query(filename)
I=imread(filename);
[c1,c2,e1,h,v,e2]=glcm_feature_extraction(I)
xlswrite('qfile.xlsx',[c1,c2,e1,h,v,e2]);%qfile is excel file for storing 6 glcm features like correaltion ,entropy etc etc.
function code for glcm feature extraction method :-
function [Contrast,cor,ener,homo,V,E]= glcm_feature_extraction(I1)
Contrast1 = graycoprops(graycomatrix(rgb2gray(I1)),'Contrast')
cor1= graycoprops(graycomatrix(rgb2gray(I1)), 'Correlation')
ener1 = graycoprops(graycomatrix(rgb2gray(I1)), 'Energy')
homo1 = graycoprops(graycomatrix(rgb2gray(I1)), 'Homogeneity')
img = double(I1);
V1 = var((img(:)))
E1=entropy(I1)
*contrast=round(Contrast1*1e1)/1e1*
cor= round(cor1* 1e1) / 1e1
ener=round(ener1* 1e1) / 1e1
homo=round(homo1* 1e1) / 1e1
V=round(V1* 1e1) / 1e1
E=round(E1* 1e1) / 1e1
-----------------------------------------------------------
while running code the bold characters"contrast=round(Contrast1*1e1)/1e1" is showing error undefined function or method 'mtimes' for input arguments of type struct?? .error in glcm_feature_extraction at contrast=round(Contrast1*1e1)/1e1.
i know question is bit longer but pls help me. thanks.
2 Kommentare
Stephen23
am 19 Aug. 2015
In future please format your code properly by selecting it and then clicking the {} Code button that you will find above the textbox. And please do not put an empty line between every line of your code, this actually makes it more difficult to read.
Guillaume
am 19 Aug. 2015
The way to format code on this forum is not by putting a blank line between each line of code, but by putting two spaces in front of each line or even simpler, just using the {} Code button.
Akzeptierte Antwort
Guillaume
am 19 Aug. 2015
Bearbeitet: Guillaume
am 19 Aug. 2015
You need to understand what the error message is telling you. It's telling you that there is no function mtimes that accept a structure as input. Now, mtimes is the same as *, so it's telling you that multiplication is not defined for structures. The only multiplicaton in the erroring line is Contrast1*1e1. Since 1e1 is obviously not a structure, Contrast1 must be.
And, indeed, if you look at the documentation of graycoprops, its output is a structure. Basically, you've misunderstood the way graycoprops works. Change the beginning of the function to:
stats = graycoprops(graycomatrix(rgb2gray(I1)), 'all'); %stats is a structure
Contrast1 = stats.Contrast; %Contrast1 is a matrix
cor1 = stats.Correlation;
ener1 = stats.Energy;
homo1 = stats.Hogemeneity;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!