My question is regarding classifying the images based on the whichever color is present more in the given image after converting the color image into gray and finding its histogram.

1 次查看(过去 30 天)
clc;
Image = imread('rose.jpg');
figure
imshow(Image);
I=rgb2gray(Image);
figure
imshow(I)
[count,x] = imhist(I)
index1 = find(x == 67);
index2 = find(x == 100);
numPixels = sum(count(index1:index2))
This code worked well up to finding the sum of number of pixels from one intensity range to other.
Now I am having few images. Some of them have red pixels in large amounts,some have white, some have blue, etc. I have to classify these images as blue, white, red, etc. after finding histogram and counting pixels in certain range. How can I do that?
Or is there any other way to do this classification?

采纳的回答

Image Analyst
Image Analyst 2016-12-3
You just need to set up some rules, like if the mean red count from the histogram is more than the mean blue and green counts. See my File Exchange for color demos. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
  9 个评论
Image Analyst
Image Analyst 2016-12-7
Did you see where I said " it was released way back in 2012 but maybe you have an ancient version of MATLAB." Well, 2010 is 2 years before atan2d was released. You'll have to see how you can build it yourself with atan() or atand(). Search the Mathworks web site for the description of atan2d().

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by