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 Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by