error inundefined function or method 'mtimes' for input arguments of type struct??
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
preeti
el 19 de Ag. de 2015
Comentada: preeti
el 19 de Ag. de 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 comentarios
Stephen23
el 19 de Ag. de 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
el 19 de Ag. de 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.
Respuesta aceptada
Guillaume
el 19 de Ag. de 2015
Editada: Guillaume
el 19 de Ag. de 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;
Más respuestas (0)
Ver también
Categorías
Más información sobre Operators and Elementary Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!