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

3 Ansichten (letzte 30 Tage)
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 Kommentar
Massimo Zanetti
Massimo Zanetti am 9 Okt. 2016
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?

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Guillaume
Guillaume am 9 Okt. 2016
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 am 9 Okt. 2016
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 am 9 Okt. 2016
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;

Community Treasure Hunt

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

Start Hunting!

Translated by