First question: Is there an easy way to read in a TIFF file and get the array of values from the TIFF into an array, or better yet, a TH2F?
Second question: is it possible to do this for any particular image in a combined TIFF file?
Basically, I’m faced with analyzing images from a CCD, and I’m just interested in grabbing the data out of TIFFs. Currently, I open up the images in matlab, and dump them to ascii arrays, then read them into TTrees, but that’s cumbersome.
Hi,
TImage/TASimage allows to read TIFF files when libtiff
library is installed on the system. For most linuxes it is so.
After image was read one can convert it to a 2D array of doubles
via root.cern.ch/root/htmldoc//TASIm … e:GetArray.
To convert 2D array to TH2D use copy constructor because TH2D class
is derived from TArray2D.
You can specify a different palette on the input which gives a
correspondence between color and double value.
You are totally confusing people bty showing very complicated solutions that nobody is going to use, while there are simple solutions.
The user simply wants to copy the array of pixels from a TIFF to a TH2 object.
Valeriy Onuchin indicated how to do the job correctly.
Now that I’m able to create and send an image of a TCanvas over the network on the fly,
I would like to do the same for postscript/pdf. Any suggestions? Thanks.
I’m doing exactly that right now, like creating a
temprary file /tmp/appname_PID.pdf, reading it back and
finally unlinking the file. Naturally, I’ll prefer the in-memory
option in future; if possible, for all the formats.
Thanks and regards,
Subir
[quote=“Valeriy Onuchin”]Hi Subir,
you can create a temporary PS/PDF file and then send it over network:
TCanvas *c1;
const char *tmp = gSystem->TempDirecotry();
char *file = ConcatFileName(tmp, "my.ps"); // pdf, svg or any image format, e.g. "my.png"
c1->Print(file);
...
I will propose to add possibility to create “in-memory” PostScript buffer.
That will allow to avoid creation of a temporary file.
With Root 5.18.00 I’m having a problem in sending in-memory png buffer
over the network; this occurs when
(1) I divide the canvas into multiple zones
(2) superimpose histograms
The following is what I do in order to get the image buffer. Do I need to
modify the code?
[code]// Now extract the image
// 114 - stands for "no write on Close"
TImageDump imgdump(“tmp.png”, 114);
c1->Paint();
// get an internal image which will be automatically deleted
// in the imgdump destructor
TImage *image = imgdump.GetImage();
char buf;
int sz;
image->GetImageBuffer(&buf, &sz); / raw buffer */
for (int i = 0; i < sz; i++)
out << buf[i];
cout << out.str();
delete [] buf;
[/code]
Suchandra has independently found a similar problem with Root 5.18.00a (in CMS) and she has also managed to isolate the problem in a little macro. Please find
I ran this macro on my linux box with the latest ROOT version. It generated two png images which look correct for me. Should I run them on some specific architecture to see the problem ?
You should also get image3.png which is created from the ImageBuffer.
The first two png files are saved directly from the canvas at two different points.
Thanks for looking into the problem.
Subir
[quote=“couet”][quote]
Suchandra has independently found a similar problem with Root 5.18.00a (in CMS) and she has also managed to isolate the problem in a little macro. Please find
I ran this macro on my linux box with the latest ROOT version. It generated two png images which look correct for me. Should I run them on some specific architecture to see the problem ?[/quote]
I do not get image3.png … I have never tested this fature of " on the flight" creation. That is new for me. I must investigate … I guess that’s something Valeri did…