Expand a stack of files to equal size

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
toolforger
Posts: 16
Joined: 2015-09-28T00:39:38-07:00
Authentication code: 1151

Re: Expand a stack of files to equal size

Post by toolforger » 2018-02-14T15:52:20-07:00

Heh. I just read a passing note that -clone isn't really copying pixels en masse.
I'm undecided whether I love the optimization, or hate the unpredictability of what operations will really cause CPU fan to spin up... anyway, I'm reevaluation options.

Thanks for all the food for thought and experimentation, I definitely got pointed in some promising directions.

snibgo
Posts: 9756
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Expand a stack of files to equal size

Post by snibgo » 2018-02-14T16:32:30-07:00

That is correct. "-clone" doesn't copy any pixel values. However, any operation that modifies pixels of a clone will first cause the pixels to be copied, before the operation itself is performed.

In your case, the operation is "-layers merge", and I expect this doesn't require any pixels to be copied to clones. But it does involve reading every pixel in all the input images to make a merged image, which is the most time-consuming part of the command, and it is almost totally a waste of time as we only want the size.

The fastest way is probably a custom program that reads the input files, calculates the maximal size (which is trivial in a C program), extends each image to that size, and writes them to disk.

However, you say you "want to align them for denoising and despeckling", so I'm not sure why you first want to make them the same size. I would expect the first stage would be to find the required offsets that align the images, so they can be merged or otherwise processed with those offsets.
snibgo's IM pages: im.snibgo.com

toolforger
Posts: 16
Joined: 2015-09-28T00:39:38-07:00
Authentication code: 1151

Re: Expand a stack of files to equal size

Post by toolforger » 2018-02-15T16:01:52-07:00

The alignment program insists that the input images are of equal size :-(

User avatar
fmw42
Posts: 22683
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Expand a stack of files to equal size

Post by fmw42 » 2018-02-15T17:40:28-07:00

What alignment program?

toolforger
Posts: 16
Joined: 2015-09-28T00:39:38-07:00
Authentication code: 1151

Re: Expand a stack of files to equal size

Post by toolforger » 2018-02-15T23:35:10-07:00

align_image_stack, a part of the Hugin suite. It's a photo stitching toolset; being a toolset, it has been used for compositing HDR images and for quality improvement.

User avatar
fmw42
Posts: 22683
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Expand a stack of files to equal size

Post by fmw42 » 2018-02-16T00:35:11-07:00

Did you try my command to get the max size and then to extent each image. See viewtopic.php?f=1&t=33496#p153646

toolforger
Posts: 16
Joined: 2015-09-28T00:39:38-07:00
Authentication code: 1151

Re: Expand a stack of files to equal size

Post by toolforger » 2018-02-23T15:15:12-07:00

@fmw42 I'm in the process of trying out various approaches (not all of them in IM).
It's a somewhat bumpy ride and will take time, but I'll come back with results once I have them.
Or with questions. Not very likely though - I read up on all the options that were mentioned here, and it looks like you provided me with enough information that I can now find my way through the docs. Many thanks for that!

Post Reply