TImage::GetPixels() appears to return wrong values

Hi,

I would like to obtain pixel values from a small region on a TImage object using:

TImage::GetPixels()

However, the values returned do not seem to be right. The returned values were much larger than expected.

For testing, I used the galaxy_image.C which imported an image from galaxy.root.

I used Root version 5.01 on RHEL 4, as well as the latest precompiled binary version for PC running on XP. They all returned the wrong values.

The additional lines of code I used for the test are given below.
Please let me what I have done wrong. Thank you in advance.

Tim

void galaxy_image4()
{
TCanvas *canv = new TCanvas(“image”, “n4254”, 40, 40, 812, 700);
canv->ToggleEventStatus();
canv->SetRightMargin(0.2);
canv->SetLeftMargin(0.01);
canv->SetTopMargin(0.01);
canv->SetBottomMargin(0.01);

// read the pixel data from file “galaxy.root”
// the size of the image is 401 X 401 pixels
TFile *gal = new TFile(“galaxy.root”, “READ”);
TImage img = (TImage)gal->Get(“n4254”);
img->Draw();
img->SetName(“n4254”);

// The following 6 lines were added to test the TImage::GetPixels()

TArrayL ff=(TArrayL)&img->GetPixels(100,100,5,5);
cout<<“Sum of 25 pixels=”<GetSum()<<endl;
Long_t *hh=ff->GetArray();
cout<<“hh[0]=”<<hh[0]<<endl;
cout<<“hh[1]=”<<hh[1]<<endl;
cout<<“hh[2]=”<<hh[2]<<endl;

// open the color editor
img->StartPaletteEditor();

// zoom the image
img->Zoom(80, 80, 250, 250);
}
galaxy_image4.C (933 Bytes)
galaxy_image4.txt (933 Bytes)

Hi,

These are normal pixel (RGB) values… and GetSum() returns the sum of these values.

Cheers,
Bertrand.