Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
image2hist.C File Reference

Detailed Description

View in nbviewer Open in SWAN
Create a 2-D histogram from an image.

void image2hist()
{
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;
h->SetBinContent(row+1,yPixels-col,grey);
}
}
h->Draw("colz");
}
#define h(i)
Definition RSha256.hxx:106
unsigned int UInt_t
Definition RtypesCore.h:46
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kCubehelix
Definition TColor.h:116
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
Image class.
Definition TASImage.h:31
2-D histogram with a double per channel (see TH1 documentation)
Definition TH2.h:357
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
Definition TStyle.cxx:1884
Author
Olivier Couet

Definition in file image2hist.C.