Specifying different colour for each block

조회 수: 1 (최근 30일)
Pat
Pat 2012년 12월 6일
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

답변 (1개)

Image Analyst
Image Analyst 2012년 12월 6일
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
Pat
Pat 2012년 12월 6일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by