c++image-processinglarge-files

How to process large images?


I need to process(export subsections) of a large image(33600x19200) and I'm not sure how to start.

I've tried simply allocating an image using openframeworks but I got this error:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

I'm not experienced with with processing images this large. Where should I start ?


Solution

  • I maintain vips, an image processing library which is designed to work on large images. It will automatically load, process and write an image in sections using many CPU cores. You can write your algorithm in C, C++, Python, PHP and Ruby. It's fast, free and cross-platform.

    There's a very simple benchmark on the vips website: load an image, crop 100 pixels off every edge, shrink by 10%, sharpen, and save. For a 5k x 5k RGB TIF on my laptop, ImageMagick takes 1.6s and 500MB of RAM, vips takes 0.4s and 25MB.

    ImageMagick is great, of course, it's free, well-documented, produces high-quality output and it's easy to use. vips is faster on large images.