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().
snehal jaipurkar
snehal jaipurkar 2016년 12월 7일
편집: snehal jaipurkar 2016년 12월 7일
Ok sir...I vl try to do that if I can get proper results by using atand( )... Thanks a lot for u help sir...

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by