FX on multiple input / output images

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Bob-O-Rama
Posts: 31
Joined: 2007-11-23T15:34:51-07:00

FX on multiple input / output images

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: FX on multiple input / output images

Post 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.
snibgo's IM pages: im.snibgo.com
Bob-O-Rama
Posts: 31
Joined: 2007-11-23T15:34:51-07:00

Re: FX on multiple input / output images

Post 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
Post Reply