Hi and thanks in advance !
I am writing a desktop application that uses industrial line-scan cameras to scan strips of photographic film. The total dimensions of the images captured is about 4,000x250,000px at 16-bits per pixel. The capture is saved by the camera as ~4,000x256px tiff chunks while scanning, as it empties out its buffers. I am also saving 1D statistical data that is used to find where the frames (individual physical images on the film) are located.
My question is what would be the most efficient way of preparing these files as the software needs to display individual extracted frames and perform image correction on these, potentially with Libvips :
Keep the images as chunks :
- Pros : no pre-processing needed since this is what the camera saves while scanning, hence they would be available immediately after the scan is done.
- Cons : the processing pipeline is made more complex by needing to load relevant chunks and concatenate them every time the user adjusts a setting.
Extract frames to individual files :
- Pros : Only one image load needed to apply a processing pipeline to a frame. The file size of each image is still manageable.
- Cons : This requires a little pre-processing to extract each frame to its own image. It's a one-time thing though.
Create a single huge image of the entire strip :
- Pros : Takes advantage of Libvips' ability to work with huge images
- Cons : long pre-processing time to concatenate and (mostly) save the large file.
I am mostly leaning towards extracting frames to their own file, and probably leverage Libvips' speed to do so, but I am very interested in hearing what people more experienced with Vips think about this topic !
Thanks a lot for reading and your time.
This is mostly an exploratory question.
libvips author here. My first thought would be to keep each 4,096 x 256 pixel chunk in a separate file and composite them for the display. You could have 1,000 open images for the 1,000 chunks then use eg.
arrayjoin
to very quickly make a single huge image from them. libvips will cache and map everything on demand for you, so performance ought to be good (as long as you can have 1,000 files open at once).But like any design like this, the best approach is to try to pick a specification for the target platform (os, memory, expected performance), a required level of performance (screen repaint speed, capture time, latency, memory use), make a tiny but representative prototype (python is good for sketching ideas), and spend some time experimenting to discover a technical solution that can meet your goals.
I'd also have a quick look at vipsdisp:
https://github.com/jcupitt/vipsdisp
It has quite a fancy threaded, async, GPU based screen repainting system you might be able to borrow ideas from. If you're targeting gtk you could perhaps even reuse some widgets.