how to find the mean colour

조회 수: 3 (최근 30일)
kash
kash 2013년 5월 18일
I have a image which consists of water ,green land and roads,I want to find mean of each colour say blue region ,green region etc
kindly help
  댓글 수: 2
Jan
Jan 2013년 5월 18일
What have you tried so far? Which toolboxes and experiences do you have?
kash
kash 2013년 5월 18일
i have image processing toolbox and others tool boxes,i tried doing segmentation and clustering the image into 4 clusters,after that i dont know who to assign colour for it

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

답변 (1개)

Image Analyst
Image Analyst 2013년 5월 18일
First you have to classify the image into the 3 categories. Then for each category, you have to mask the original image and measure the mean for pixels in that category. See my File Exchange for color classification demos: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
  댓글 수: 3
Image Analyst
Image Analyst 2013년 5월 18일
You can use those to classify images into a limited number of colors. Or try rgb2ind() or kmeans().
kash
kash 2013년 5월 24일
I have uploaded two images
my code
clc
clear all
close all
he = imread('3.jpg');
K1=[0 0 1];K2=[0 0.8 0];K3=[1 0 0];K4=[1 0 1];
lab_he=rgb2hsv(he);
ab=double(he);
nrows = size(ab,1);
ncols = size(ab,2);
ab = reshape(ab,nrows*ncols,3);
nColors = 4;
C=double(he(1:4,1:3));
[cluster_idx cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean', ...
'Replicates',1,'start',C);
segmented_images = cell(1,3);pixel_labels = reshape(cluster_idx,nrows,ncols);
rgb_label = repmat(pixel_labels,[1 1 3]);
for k = 1:4
color = he;
color(rgb_label ~= k) = 0;
segmented_images{k} = color;
end
figure,imshow(segmented_images{1}), title('objects in cluster 1');
figure,imshow(segmented_images{2}), title('objects in cluster 2');
figure,imshow(segmented_images{3}), title('objects in cluster 3');
figure,imshow(segmented_images{4}), title('objects in cluster 3');
figure,imshow(he)
figure,imshow(ind2rgb(pixel_labels, [K2;K1;K3;K4]))
Mean1=mean(mean(segmented_images{1}(:)))
Mean2=mean(mean(segmented_images{2}(:)))
Mean3=mean(mean(segmented_images{3}(:)))
Mean4=mean(mean(segmented_images{4}(:)))
I like to colour water portion in red ,green portion in blue etc
so i made 4 clusters,wen i took the mean of each cluster for water portion the value is different for those two images,please tell how to compute the water colour which must be same for two images,omly ten it is poosible to assign red colour for it

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

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by