I need to store images (also files in other formats such as Igor binaries etc) in a root database. These images will be related to the object data stored in root files. The purpose is to provide functionality such as “Download/Get all image traces for the current object”, “Get Igor binaries for the object” etc.
I looked at TFolder, TDirectory classes; but was not able to figure out how to copy the images (and other) files to a directory (or folder) in a root database.
I wanted to know if the above mentioned tasks can be performed using the root database files. If yes, if provide me links to some exaples etc.
If not, i will consider using the file system for storing the image (and other) files and provide that information in the object data.
Thanks in advance,
You can save any object (ROOT object or your own objects) in a ROOT file
with, eg with
where keyname is an identifier to retrieve your object in another session.
MyClass must have a valid dictionary.
You can use the class TASImage to save images to a ROOT file.
For images I already looked at the TASImage class. What about other data formats i.e. text, binary (I have Igor binary files that are used for displaying the data in Igor program). Do I have to develop custom classes representing these.
Further, the Igor files are really huge i.e. in hundreds of MBs ? will it be feasible to store them in the root database.
Also storing TASImage in root file worked well; but I was not able to read at (please look at the following code)
TASImage* img = new TASImage(“radio2.jpg”)
TFile f (“test.root”,“recreate”)
TASImage* i =(TASImage*) f.Get(“Image0”)
*** Break *** segmentation violation
Generating stack trace…
0x4197a8a0 in from /programs/root/lib/libASImage.so
0x406a2aae in G__call_cppfunc + 0x263 from /programs/root/lib/libCint.so
0x406923d7 in G__interpret_func + 0x6e4 from /programs/root/lib/libCint.so
0x4067a026 in G__getfunction + 0x134a from /programs/root/lib/libCint.so
0x406fdf28 in G__getstructmem + 0x82a from /programs/root/lib/libCint.so
0x406f8041 in G__getvariable + 0x4db from /programs/root/lib/libCint.so
0x40671622 in G__getitem + 0x5c1 from /programs/root/lib/libCint.so
0x4067023a in G__getexpr + 0x783e from /programs/root/lib/libCint.so
0x406b79c0 in G__exec_function + 0x1d5 from /programs/root/lib/libCint.so
0x406be60d in G__exec_statement + 0x23eb from /programs/root/lib/libCint.so
0x4065944f in G__exec_tempfile_core + 0x2ce from /programs/root/lib/libCint.so
0x4065962c in G__exec_tempfile_fp + 0x22 from /programs/root/lib/libCint.so
0x406c679e in G__process_cmd + 0x456b from /programs/root/lib/libCint.so
0x40191d69 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) + 0xa9 from /programs/root/lib/libCore.so
0x40103d2c in TApplication::ProcessLine(char const*, bool, int*) + 0x596 from /programs/root/lib/libCore.so
0x40feaec5 in TRint::HandleTermInput() + 0x1dd from /programs/root/lib/libRint.so
0x40fe9e16 in TTermInputHandler::Notify() + 0x24 from /programs/root/lib/libRint.so
0x40feb730 in TTermInputHandler::ReadNotify() + 0x12 from /programs/root/lib/libRint.so
0x401fbb63 in TUnixSystem::CheckDescriptors() + 0x143 from /programs/root/lib/libCore.so
0x401fb143 in TUnixSystem::DispatchOneEvent(bool) + 0x161 from /programs/root/lib/libCore.so
0x4015fa98 in TSystem::InnerLoop() + 0x18 from /programs/root/lib/libCore.so
0x4015fa3d in TSystem::Run() + 0x6f from /programs/root/lib/libCore.so
0x4010479c in TApplication::Run(bool) + 0x32 from /programs/root/lib/libCore.so 0x40fea9c1 in TRint::Run(bool) + 0x327 from /programs/root/lib/libRint.so
0x080488dd in main + 0x71 from /programs/root/bin/root.exe
0x4111d768 in __libc_start_main + 0xf8 from /lib/tls/libc.so.6
0x080487e1 in _Unwind_Resume + 0x31 from /programs/root/bin/root.exe
you’re using the wrong file to Get() the TASImage, at least in your example.
TASImage* i =(TASImage*) f.Get(“Image0”)[/quote]
It is a typing error in the posting. I am reading the correct file and getting a pointer to the TASImage object . But when I try to Draw the image; I get the error as indicated in my last posting.
as Rene pointed out, look at $ROOTSYS/tutorials/galaxy_image.C and you’ll see how to save a TASImage.
I have looked at the example. I dont have any probelms in saving the image . Its just that when I read it (and I dont read a null pointer by the way). I can not use the pointer to the image as all the calls to the object crash.
But looking at the fact that I can instantiate an image object and also Draw it without any probelms. Do you think I am missing some libraries on my system that are causing the read probelm.
I tried your code, and I’m not getting any crash - so I cannot reproduce that part. It might have been fixed - what root version arre you using? But I don’t get an image drawn either, as this is not the way to store or load TASImage’s image. For me, running your code, TASImage says “image not set”. Again, please look at the tutorial.
I realize now that the pixel matrix is not saved to the file.
Valeriy is working on this problem.
[quote=“brun”]I realize now that the pixel matrix is not saved to the file.[/quote]Right, and $ROOTSYS/tutorials/galaxy_image.C shows that, and how to store it nevertheless. It’s good to hear that Valeriy is trying to implement it, though.