Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
hist2image.C File Reference

Detailed Description

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

#include <TAttImage.h>
void hist2image()
{
TCanvas *canv = new TCanvas("image", "xygaus + xygaus(5) + xylandau(10)");
canv->ToggleEventStatus();
canv->SetRightMargin(0.2);
canv->SetLeftMargin(0.01);
canv->SetTopMargin(0.01);
canv->SetBottomMargin(0.01);
// histogram as image (hist taken from draw2dopt.C)
TF2 *f2 = new TF2("f2", "(xygaus + xygaus(5) + xylandau(10))", -4, 4, -4, 4);
Double_t params[] = {130, -1.4, 1.8, 1.5, 1, 150, 2, 0.5, -2, 0.5, 3600, -2, 0.7, -3, 0.3};
f2->SetParameters(params);
TH2D *h2 = new TH2D("h2", "xygaus + xygaus(5) + xylandau(10)", 100, -4, 4, 100, -4, 4);
h2->FillRandom("f2", 40000);
img->SetImage((const Double_t *)h2->GetArray(), h2->GetNbinsX() + 2, h2->GetNbinsY() + 2, gHistImagePalette);
img->Draw();
img->StartPaletteEditor();
}
double Double_t
Definition RtypesCore.h:59
R__EXTERN TImagePalette * gHistImagePalette
Definition TAttImage.h:109
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
The Canvas class.
Definition TCanvas.h:23
virtual void SetParameters(const Double_t *params)
Definition TF1.h:685
A 2-Dim function with parameters.
Definition TF2.h:29
2-D histogram with a double per channel (see TH1 documentation)
Definition TH2.h:356
An abstract interface to image processing library.
Definition TImage.h:29
static TImage * Create()
Create an image.
Definition TImage.cxx:35
Author
Valeriy Onuchin

Definition in file hist2image.C.