0

I have a problem with my code:

cout << "image root"; 
fflush(stdin); 
cin.getline(dir_imd,2048);
TIFF* tif = TIFFOpen(dir_imd, "r");

It's quite simple, but when I try to load a image larger than 50 MB the code gives me a message saying the image cannot be open. I'm using the libtiff library.

Any idea about what is the problem?

Andreww
  • 1
  • 2
  • How much memory does your system have? Not sure that matters, but depends on what TIFFOpen is doing. – Eugene K Feb 18 '15 at 18:22
  • The system has 4 GB DDR3 RAM. I'm not sure what TIFFOpen is doing because the debugger doesn't allow me to follow the instructions inside the library. – Andreww Feb 18 '15 at 18:47
  • In my opinion I think that you are right and TIFFOpen might fail to open a file because the file is out of memory but I don't know how to solve it. – Andreww Feb 18 '15 at 18:55
  • If I try to use CImg header to open the image, the program gives me the next exception: " Failed to allocate memory (652.2 Mio) for image (6482,6594,1,8)" – Andreww Feb 18 '15 at 19:07
  • Is the test file you're using 652MB or is it closer to 50MB? Big difference in the required memory. Opening all of a 652MB file on 4GB might not be possible. You have to figure out how to stream it, or cut it into chunks. – Eugene K Feb 18 '15 at 19:16
  • I haven't used LibTiff personally, but the other problem might be that you need properly allocate memory onto the heap for TIFFOpen. Look at some 'alloc' functions in the library. – Eugene K Feb 18 '15 at 19:20

1 Answers1

-1

Try this:

TIFF* tif = TIFFOpen(dir_imd, "mr");

If memory serves this disables memory-mapping of files. I have found that when dealing with large files that this can solve some crashes.