i've divide the image into non-overlapping blocks. and after that i've calculated the GLCM MEAN... i want to color only those blocks whose GLCM MEAN are the same

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..

 Accepted Answer

If one block as GMCM mean of (say) 50, and another is 54, then because they differ by 4, you want them colored the same. Now if a third block is 58, then because it is different by only 4 from the 54, it needs to be colored the same as the 54. Which is colored the same as the 50. So now you have the 50 through 58 range all colored the same.
By induction, we can establish that all values must be colored the same, so there is nothing to do.

16 Comments

well... ok sir . you can just tell me the way to color only those blocks whose glcm mean values are exactly same.
like
if block54 and block 110 = 1241 then they are colored with let say red color
if block 64 and block 143 = 1193 they are colored with let say green color and so on...
rest i can try by myself..
tell me by writing few lines of code...
i've tried the link u've mentioned..it shows blocks in the form of bars of different color in the grayscale range...
i want that the similar blocks should be in color like if block 54 and block 110 have value 1241 the its pixel value should be red...
forexample...if i've a block having picture of apple and other block also have picture of apple then the block should be of red apple i.e color the pixels with red color....
imagesc() function output the image in the form of bars...this i dont want...
can u tell me the way to do this sir.
You can make up whatever kind of colormap you want. Just assign RGB values to each row in the N by 3 array and send it in to colormap(). If you want a more continuous looking colormap, use 256 rows instead of 64 or fewer rows.
i've used
colormap(hot);
it colors all the blocks with the same hot color.
can you tell me by writing some piece of code as i m novice.
Remember, GLCM is, by definition, an operating on gray levels. Gray levels cannot distinguish between a brightness caused by red compared to a brightness caused by blue (or green.) So you cannot expect to be able to map your mean GLCM values to the color of the original RGB image, as the same gray will be caused by quite different colors.
ok sir... is there any other way to color the blocks between gray scale range....
mine task is to color those blocks which have same glcm values...
can u tell me...
colormap(hot) i tried it colors all the blocks..
can u tell me how can we apply condition to show blocks which have same GLCM Mean?
Follow this example:
fun = @(block_struct) ...
std2(block_struct.data) * ones(size(block_struct.data));
I2 = blockproc('moon.tif',[32 32],fun);
imagesc(I2);
colormap(flag);
the code i've mentioned above i modified it as:
glcmL(blockNumber)=glcml;
colormap(flag);
glcmR(blockNumber)=glcmr;
is it correct? the bars i donot want thats why m not using imagesc();
the output it produces not as per my requirement.
i hope sir u understand what m trying to say...
as m doing my project i want to show blocks visually that the blocks having the same colors are duplicate blocks...
the output it produces consists of tiny tiny squares of different colors.. but the other person cannot recognize it what is the picture behind it...
i want the picture to be remain the same in background it highlights the same block having GLCM mean Vlaues to be of red color..
mine original image is:
after dividing it into 8x8 blocks(total of 64 blocks) i got
when i applied the
imagesc(glcmL);
colormap(flag);
i got
i have shown u the result for 8x8.. but i m working on 16x16....
i want that like in the following image
if the glcmL values of BLOCK 28 and BLOCK 39 have the same value then only these blocks have color summer image behind the same( image too is visible) rather than all the blocks with summer color
if glcmL of BLOCK 27 and BLOCK 43 have same glcmL value then the color of these block sholud be the same like blue image behind remain the same...and so on...
reply as soon as possible sir

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!