Page 1 of 1

FX on multiple input / output images

Posted: 2018-04-20T07:30:04-07:00
by Bob-O-Rama
I have a ugly MSVC++ thing I wrote which uses Magick++ to manipulate a series of images ( think a filter for processing video frames ) so you have a series of images a[0...N] and you take a range of them, do some compute task, and output an image in a new series.

From one output image to the next, there will be significant overlap in terms of the input images used. So one image might be derived from input images a[23, 24, ... 35] the next from a[25,26,...37]

So significant time is saved, even on top of disk caching in the OS, if you create an in memory cache of image objects and recycle them. But this is about the only thing I need to write code for otherwise the operations could be reduced to convert operations scripted from the command line.

Basically what is being saved is the overhead of creating the image objects and then destroying them only to need many of them again for the next output frame.

Is there some means to get the existing CLI tools to do this? E.g. cache and recycle rather than reread and recreate frequently accessed images at rest? Or am I still needing to create an application rather than a script?

Or is there some pipeline framework that is better suited to these sliding window sort of repetetetive functions?

-- Bob

Re: FX on multiple input / output images

Posted: 2018-04-20T08:33:33-07:00
by snibgo
You could do this with a command line script by first reading all the input images. For each window, start a new list with "(", then clone the required images, do the work, save the result(s) and end the list with ")". This script could be written by another script. It needs enough memory to store all the input images. A more complex script would read and delete as needed.

An alternative API such as Python could be used, to do what your CPP program does.

Another possibility is for your CPP program to do the work of reading and forgetting the input images, and at for each window it passes an image list and a list of CLI options to ImageMagick. It could read the CLI option list from a file or its own command line. So the CPP program is fairly simple, needs no more memory than is needed for each window, but leaves the flexibility to do whatever processing you need.

Re: FX on multiple input / output images

Posted: 2018-04-23T14:06:46-07:00
by Bob-O-Rama
I will give the first suggestion a try. I also took note of the MPC option. I am not sure that really helps if each instance of the IM tools has its own separate cache and I would simply be reading N copies of the same image into memory between N tasks that involve a common image.

Thanks!

-- Bob