Image 2Hist

Create a 2-D histogram from an image.

Author: Olivier Couet
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Thursday, February 25, 2021 at 09:14 AM.

In [1]:
TASImage image("$ROOTSYS/tutorials/image/rose512.jpg");
UInt_t yPixels = image.GetHeight();
UInt_t xPixels = image.GetWidth();
UInt_t *argb   = image.GetArgbArray();

TH2D* h = new TH2D("h","Rose histogram",xPixels,-1,1,yPixels,-1,1);

for (int row=0; row<xPixels; ++row) {
   for (int col=0; col<yPixels; ++col) {
      int index = col*xPixels+row;
      float grey = float(argb[index]&0xff)/256;

Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1

Draw all canvases

In [2]: