error inundefined function or method 'mtimes' for input arguments of type struct??
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Stephen23
le 19 Août 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
le 19 Août 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.
Réponse acceptée
Guillaume
le 19 Août 2015
Modifié(e) : Guillaume
le 19 Août 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;
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Operators and Elementary Operations 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!