Draw image from raw data

I have images in a file in txt format, showing values about the intensity, file look likes

0 0 0 0 0 0 0 0 0
0 0 12 18 60 90 30 20 0
0 0 11 12 23 31 21 9 0
0 0 0 7 12 21 11 6 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0

I want to draw image showing different colors for different intensity. It is easy to draw this in Matlab, where we have to give only file it will draw image. I want to draw these images ROOT. can you suggest me how to do that.

You can find below a script reading a text file with an arbitrary number of lines and columns, filling a TH2 and drawing it.
You can change the drawing option as you like.

Rene

[code]TH2 *chandra(const char *filename=“chandra.txt”) {

//first pass on file to count lines and columns
FILE *fp = fopen(filename,“r”);
char line[80]; //put more if needed
int nlines = 0;
int ncol = 0;
while (fgets(line,80,fp)) {
if (!nlines) { //count columns on first line
char *s = line;
while (s) {
s = strtok(s," ");
if (!s ) break;
if (*s == ‘\n’) break;
ncol++;
s += strlen(s) + 1;
}
}
nlines++;
}
fclose(fp);

//create TH2 and fill it with a second pass on the file
TH2F h = new TH2F(“h”,filename,ncol,0,ncol,nlines,0,nlines);
ifstream in;
in.open(filename);
for (int j=0;j<nlines;j++) {
for (int i=0;i<ncol;i++) {
int z; in >> z;
h->SetBinContent(i+1,j+1,z);
}
}
in.close();
h->SetEntries(nlines
ncol);
h->Draw(“colz”);
return h;
}
[/code]

Hi,
you can create an image by using one of the ctors.
TASImage(const char* name, const TArrayD& imageData, UInt_t width, TImagePalette* palette = 0)
TASImage(const char* name, const TVectorD& imageData, UInt_t width, TImagePalette* palette = 0)
TASImage(const char* name, const Double_t* imageData, UInt_t width, UInt_t height, TImagePalette* palette = 0)

Regards. Valeriy