Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

i've a matrix B. i've calculated the mean, entropy mean and glcm mean of each row. now i wan t the new matrix having these three as columns and rows are same a B

Asked by Jassy on 9 May 2013

i've a gray scale image and i've divided it into overlapping blocks.

each block i've stored in the form of vector in a matrix B.

From the matrix B ,i've calculated the MEAN, GLCM MEAN and ENTROPY MEAN of each and every blocks.

i want to create a new matrix having MEAN, GLCM MEAN and Entropy meaqn as three columns and number of rows same as B.

the code i wrote is:

 for i=1:length(B)
    %Reading First Vector
    vector1=B(i,:);
    match1=i;
    block1=index(match1);
    rowstart1=startRow(match1);
    colstart1=startCol(match1);
    oneBlock1=grayImage(rowstart1:rowstart1+(blockSizeR-1),colstart1:colstart1+(blockSizeC-1));
    %Calculating Mean
    mean1=floor(mean2(oneBlock1));
    %Calculating GLCM Mean
    glcml1=0;
    glcmr1=0;
    glcm1=0;
    glcm1=graycomatrix(oneBlock1);
    for x=1:overlapR
       for y=1:overlapC
           glcml1=glcml1+x*glcm1(x,y);
           glcmr1=glcmr1+y*glcm1(x,y);
           glcmLR1=abs(glcml1-glcmr1);
        end
    end
    glcmLRD1(index1)=glcmLR1;
    disp(glcmLRD1);
    %Calculating Entropy
    entropy1=entropyfilt(oneBlock1);
    entropyMean1(index1)=floor(mean2(entropy1));
    %Creating new matrix with 3 columns corresponding to Intensity Mean, GLCM Mean and Entropy Mean
    newB(index,1)=mean1
    newB(index1,1)=glcmLR1
    newB(index1,2)=entropyMean1;
    index1=index1+1;
    New(rowstart1 : rowstart1 + (blockSizeR - 1), colstart1 : colstart1 + (blockSizeC - 1),[1 2 3])=0;  %assign black color
end
disp(newB);

here newB is my new matrix having columns mean glcm and entropy

but it shows error that the dimension mismatch..

plz help me in solving my problem..

4 Comments

Image Analyst on 9 May 2013

Aren't they non-overlapping? Anyway, did you know that graycomatrix doesn't look at all 8 directions? It only looks at one direction. To get all 8, you'd have to look at the 4 directions - top row and right. Only 4 instead of 8 otherwise you'd be double counting (looking below and above will count that pair of pixels twice).

Jassy on 9 May 2013

sir can u tell me by writing some piece of code of 4 direction plz?

so that i can understand

Jassy on 9 May 2013
 @ Matt J 

Subscripted assignment dimension mismatch.

Error in overlapLexicoFeatureMatrix (line 130)

    newB(index1,3)=entropyMean1;
Jassy

Products

No products are associated with this question.

1 Answer

Answer by Matt J on 10 May 2013

The variable entrpoyMean1 is not a scalar, as DBSTOP will show you, and therefore

newB(index1,3)=entropyMean1;

does not make sense. Possibly, you meant to have

 newB(index1,3)=entropyMean1(index1);

1 Comment

pammy on 10 May 2013

thank you sir

Matt J

Contact us