Specifying different colour for each block

1 view (last 30 days)
Pat
Pat on 6 Dec 2012
I got the below coding from demo in one site where the image is divided into blocks..
clc;
close all;
rgbImage = imread('im9.bmp')
rgbImage=imresize(rgbImage,[256 256]);
imshow(rgbImage);
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
drawnow;
[rows columns numberOfColorBands] = size(rgbImage)
blockSizeR = 64;
blockSizeC = 64;
wholeBlockRows = floor(rows / blockSizeR);
blockVectorR = [blockSizeR * ones(1, wholeBlockRows), rem(rows, blockSizeR)];
wholeBlockCols = floor(columns / blockSizeC);
blockVectorC = [blockSizeC * ones(1, wholeBlockCols), rem(columns, blockSizeC)];
if numberOfColorBands > 1
ca = mat2cell(rgbImage, blockVectorR, blockVectorC, numberOfColorBands);
else
ca = mat2cell(rgbImage, blockVectorR, blockVectorC);
end
plotIndex = 1;
numPlotsR = size(ca, 1);
numPlotsC = size(ca, 2);
for r = 1 : numPlotsR
for c = 1 : numPlotsC
subplot(numPlotsR, numPlotsC, plotIndex);
rgbBlock = ca{r,c};
imshow(rgbBlock);
[rowsB columnsB numberOfColorBandsB] = size(rgbBlock);
plotIndex = plotIndex + 1;
end
end
I have 16 blocks as shown in link
http://imgur.com/xmT3Q
now in this some blocks may have same mean value,i have to give same colours for blocks having same mean value,and other colours for other blocks,please help

Answers (1)

Image Analyst
Image Analyst on 6 Dec 2012
I don't know what mean value i means in regard to a color image. Please explain. Also, you should know by now how to format your question into code and non-code parts, and to make links to web sites.
  1 Comment
Pat
Pat on 6 Dec 2012
I have 16 values from my above code ,in that i have to take mean or average for each block
1.i will have 16 mean values one for eachblock
2.i have to make each block a different colour,if there are same mean values those block must be of same color
3.for example if block 4 and 10 have same mean value ,those blocks must be of same colour
please help

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!