8 bit map to array


I have 8 bit bmp file, I would like to have an array of its value in decimal(0~255).
And in my understanding, 8 bit format is a grayscale luminosity and “TASImage” provides
a solution to extract RGB, “GetArgbArray”, so I may use it as

TASImage *file = TImage::Open(“sample.bmp”);
UInt_t *rgb = file->TImage::GetArgbArray();

for ( … i for height…)
for (…j for width…)
UInt_t val = rgb[i*width+j] & 0xff; // to get LSB?

My question is it is correct way or there is better simple way.
Also I would like to create image again as grayscale after some work
like binarization, (0 or 255), in that case, what number of palette I can use?

Thanks in advance.

The examples in $ROOTSYS/tutotrials/image show you how to use ArgbArray
May be provide an running example showing your problem ?