how to generate a color histogram by concatenating the higher order two bits of each color component

조회 수: 2 (최근 30일)
I want to use matlab to generate a color histogram. The standard way to do that is to concatenate the higher order two bits for each of the Red (R), Green (G) and Blue (B) values in the RGB space, which forms a 64-bin histogram. I am not quite clear about the concatenating process.
It is easy to generate a histogram for each color channel, but how to concatenate three channels to form one 1-D histogram. In particular, what does the higher order two bits mean? how does that end up with a 64-bin histogram?
  댓글 수: 1
Massimo Zanetti
Massimo Zanetti 2016년 10월 9일
What is the reference where you get this "2 higher order bits" method?
Another question, what is depth of you color channels? 8-bit? 16-bit?

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

답변 (3개)

Guillaume
Guillaume 2016년 10월 9일
I'm not sure where you've seen this standard way. I've never heard of it.
In any case, if I understood correctly:
img = imread('peppers.png'); %demo image
highbits = idivide(img, 64); %only keep the two high bits of each image. Assumes uint8 image
%in R2016b only:
groupedbits = sum(highbits .* permute(uint8([16 4 1]), [1 3 2]), 3);
%in earlier versions:
groupedbits = sum(bsxfun(@times, highbits, permute(uint8([16 4 1]), [1 3 2])), 3);
You can then build your histogram any way you want
histogram(groupedbits, 64, 'BinMethod', 'integers')

Image Analyst
Image Analyst 2016년 10월 9일
Why can't you just concatenate the counts from each color channel together?
rgbImage = imread('peppers.png');
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
countsR = imhist(redChannel, 21);
countsG = imhist(greenChannel, 21);
countsB = imhist(blueChannel, 21);
allThree = [countsR; countsG; countsB]'

Walter Roberson
Walter Roberson 2016년 10월 9일
highred = uint8(floor( double(rgbImage(:, :, 1)) / 2^6));
highgreen = uint8(floor( double(rgbImage(:, :, 2)) / 2^6));
highblue = uint8(floor( double(rgbImage(:, :, 3)) / 2^6));
output = highred * 2^4 + highgreen * 2^2 + highblue;

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by