Cannot call StartPaletteEditor()

Hello,

I’m writing a simple program to read an image and calculate the centroid of a maximum…

I would like to have the same options as there is on the online example galaxy_image.C, where I call:

img->StartPaletteEditor();

My macro is:

void Image()
{
TImage *image = TImage::Open(“Image.png”);
unsigned int yPixels = image->GetHeight();
unsigned int xPixels = image->GetWidth();
unsigned int *argb = image->GetArgbArray();

printf(“The image is %d x %d pixels with %d Digital Levels\n”,yPixels,xPixels,*argb);

//TH2D* h = new TH2D(“h”,“Image Histogram”,xPixels,-1,1,yPixels,-1,1);

for(int row=0;row<xPixels;++row){
for(int col=0;col<yPixels;++col){
Centroid calculus…
}
}

image->Draw(“colz”);
image->StartPaletteEditor();
}

When I start the program, ROOT tells me:
“Warning in TASImage::StartPaletteEditor: palette can be modified only for data images”

How can I set the editor? Sorry, I’m still a beginner?

Thank you very much.
Cheers.
Leonardo.

is galaxy_image.C working for you ?

Hello,

Yes, it is working quite normal.

When I run my program, ROOT visualizes the image (attached), but it doesn’t start the palette editor.

Thank again.

So, if for you the galaxy example is working just do the same and it should work …