View Full Version : buffered I/O

05-12-2009, 06:25 AM
Does anybody know some way to read image files on pieces? IMAGE_READ
function loads the whole files into memory and when the files are too big, we
get problems running multiple instances of the PV-WAVE scripts. On the
other side, IMAGE_READ copes successfully with plenty of file format...
Would be very grateful for any hints for further reading or testing.
Cheers & many thanks in advance,

05-12-2009, 09:29 AM
If the image format is not TIFF16 or DICM, then the IMAGE_READ function internally calls FILEIO_READ_IMAGE which is not open-source and not documented, so as a result you probably cannot buffer read it.

If it is TIFF16 or DICM, then you could clone IMAGE_READ and change the READU size to read only a portion of the image, but you may still have problems separating data from header.

Another idea would be to read in the whole image with IMAGE_READ, and then break the pixelmap into buffer blocks and write them to disk using mutliple calls to SAVE. Free the memory used by the image and then read the buffers back to memory using RESTORE.

Hope this helps.

05-12-2009, 01:11 PM
The ASSOC function may help you too. Take a look at the help page for this Standard Lib routine, and there is also some discussion of its use in the PV-WAVE Programmer's Guide, Working With Data Files --> Associated Variable Input and Output.

05-13-2009, 05:26 AM
Thank you really very much for the fast replies! I am going to test now the
suggested approaches and hope that this time the memory usage does not
go over the boundaries.

Best regards,