how to sort CORRELATION property of graycoprops?

1 view (last 30 days)
sorting of correlation values is done. it works well with 2x2 but not working with 16x16 or 8x8.. can u tell me why is it so...
can u tell me how to do it?
blockSizeR = 128;% Rows in block.
blockSizeC = 128; % Columns in block.
for row = 1 : blockSizeR : rows
for col = 1 : blockSizeC : columns
row1 = row;
row2 = row1 + blockSizeR - 1;
row2 = min(rows, row2);
col1 = col;
col2 = col1 + blockSizeC - 1;
col2 = min(columns, col2);
oneBlock = grayImage(row1:row2, col1:col2);
subplot(2,2,blockNumber);
imshow(oneBlock);
glcm=0;
glcm=graycomatrix(oneBlock);
stats=graycoprops(glcm,'correlation');
fprintf('\ncorrelation values are\n %d',stats);
caption2 = sprintf('Block #%d\n of %d', blockNumber,blocks);
title(caption2, 'FontSize', fontSize);
blockNumber = blockNumber + 1;
end
end
[sortedStats,blockNumber]=sort([stats.Correlation]);
fprintf('\nblock #%d = %f\n',[blockNumber(:),sortedStats(:)].');
here i m dividing the image into non-overlapping blocks of size 2x2. i m caculating the glcm of each and every block and after that m caculating the correlation of each block..

Accepted Answer

Image Analyst
Image Analyst on 7 Mar 2013
I think we talked about this before. stats is a structure so you need to fprintf individual structure members. You can't fprintf() the whole structure with a %d.
  3 Comments
angel
angel on 7 Mar 2013
Edited: angel on 8 Mar 2013
sir the above code work well for block size 2x2 (blockSizeR=128, blockSizeC=128)and shows the result in sorted order according to the correlation values.
like
block #4 = 0.828825
block #2 = 0.841469
block #3 = 0.851310
block #1 = 0.926607
but when I change the block size to 8x8 (blockSizeR=32,blockSizeC=32) or 16x16 (blockSizeR=16,blockSizeC=16) it does not work..i.e it show the result of only block 1 rather than showing block 1 through block 64 or 256.... like
block #4 = 0.846963
block #2 = 0.858790
block #3 = 0.866082
block #1 = 0.954553
can u tell me what's the problem in it as i m unable to recognize it?
reply soon
angel
angel on 19 Mar 2013
can u tell me what is the problem in it? it only represents 4 blocks rather than 64 or 256 according to block size

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!