32 (or 24) bit color palette for 2D histograms

I’m working with .tif images which are in 32 bit ARGB format. (alpha, red, green, blue). I’ve written code which extracts the alpha, red, green and blue components and puts them into their own 2D histograms. But what I would really like is to have a TH2I histogram and a 32bit (or 24 bit, I can strip off the alpha portion of the ARGB pixel value) color palette so when I call the ->Draw(“col”) member function, the 2D hist is drawn with the full 32bit color scheme. Any pointers?

Thanks.

So you have one histogram with R value one with G and one with B ? and you would like to see a plot where each bin appears with the right RGB value ?

TH2I *pRGBHist = new TH2I(....);

int Bluepixelvalue = 0xff0000; // Pure blue
int Yellowpixelvalue = 0x00ffff; // pure yellow (equal mix of red and green)

pRGBHist->SetBinContent(1,1, Bluepixelvalue);
pRGBHist->SetBinContent(2,2, Yellowpixelvalue);

pRGBHist->Draw("col"); // displays binx 1, biny 1 in blue, binx 2, bin2 in yellow.

I think this code snipit explains what I’d like to do.

Not that will not work. you would need to define the palette to match these values … not easy …
I guess you better use TImage to do that. See:
https://root.cern/doc/master/group__tutorial__image.html

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.