George Profenza George Profenza - 10 days ago 6
C++ Question

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 ?

Answer

std::bad_alloc occurs, because you dont have enough memory available to hold the whole image.

In order to work with such big things, one has to split them, e.g threat the picture as a set of subsections / subpictures with a well defined size (e.g 1000x1000) and process them one by one.

The other solution is simply to throw as much memory into your system as you can. If you have the money and the program should only run on one specific machine, its surely an option, but I think its clear which of the both solutions is the better one ;)