i've divided the image into non-overlapping blocks
the code for the above is as follows
blockSizeR = 16;% Rows in block.
blockSizeC = 16; % Columns in block.
% Figure out the size of each block.
wholeBlockRows = floor(rows / blockSizeR); wholeBlockCols = floor(columns / blockSizeC); blockNumber = 1; glcmL=[]; glcmR=[]; S=[]; 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); % Extract out the block into a single subimage.
oneBlock = grayImage(row1:row2, col1:col2); subplot(12,16,blockNumber); imshow(oneBlock); glcml=0; glcmr=0; glcm=0; glcm=graycomatrix(oneBlock,'NumLevels',16); for x=1:wholeBlockRows for y=1:wholeBlockCols glcml=glcml+x*glcm(x,y); glcmr=glcmr+y*glcm(x,y); end end glcmL(blockNumber)=glcml; glcmR(blockNumber)=glcmr; caption2 = sprintf('Block #%d\n of %d', blockNumber,blocks); title(caption2, 'FontSize', fontSize); blockNumber = blockNumber + 1;
end
end fprintf('\nsorted GLCM Mean values along left hand side are:\n'); [S,blockNumber]=sort(glcmL); fprintf('\nBlock #%d = %d\n', [blockNumber(:), S(:)].' ); fprintf('\nsorted GLCM Mean values along right hand side are:\n'); [S,blockNumber]=sort(glcmR); fprintf('\nBlock #%d = %d\n', [blockNumber(:), S(:)].' );
In the above code there are blocks having the same or nearly same GLCM MEAN values like
block 54 and block 69=1241, block 69 = 1242
block 64 and block 143 = 1193, block 96 = 1192
there are other blocks like
block 71 = 1381, block 105 = 1383, block 90 = 1387
and so on…
i want to color these type of blocks.
plz guide me to do so..
Best Answer