taking small slices from multiple images and blending them?

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?".
Post Reply
cowanrg
Posts: 3
Joined: 2012-12-24T12:54:18-07:00
Authentication code: 6789

taking small slices from multiple images and blending them?

Post by cowanrg »

So, I have a photography project where I ultimately want to take a lot of images and blend them together in strips. For instance, if I have 3 images, one black, one green, and one yellow, and they are all 60 pixels wide, I want there to be 3 vertical bands (red, green, black), and have a ~5-10 pixel blend in between each. so, each strip will kinda blend/fade into the next one. I was able to successfully use Image Magick to make the strips by determining how many files are in the sequence, how wide they are, and how wide the total image is, etc. But, there is of course no overlap, and I want there to be an overlap/blend between each.

the final composite would look something like this:

Image

the source files would be three solid images (black, green, yellow). Of course, for my final project, I will be using actual image files. I can pretty easily do this by hand in Photoshop, but the goal is to do this with several hundred images, all blended. Think of a day to night transition of a time-lapse, or something like that. Any help? I'm pretty new to Image Magick.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: taking small slices from multiple images and blending th

Post by snibgo »

First, break the problem down into simpler problems, such as abutting two images with a transition between them.

Suppose we have two images 60x60 pixels. Scripts are Windows; adjust as required. We get pure green from the colour name "lime".

Code: Select all

"%IMG%convert" -size 60x60 xc:red red.tiff
"%IMG%convert" -size 60x60 xc:lime green.tiff
Suppose we want a 10 pixel overlap. Then the final image will be 60*2-10 = 110 pixels wide. We can place each image on a canvas of this size:

Code: Select all

"%IMG%convert" ^
  -size 110x60 canvas:grey ^
  red.tiff ^
  -composite ^
  redLeft.tiff

"%IMG%convert" ^
  -size 110x60 canvas:grey ^
  green.tiff ^
  -gravity East ^
  -composite ^
  greenRight.tiff
I choose grey for the canvas, just so I can see it. It won't show in the final image.

Create a mask: black on the left, white on the right, with a smooth fade in the middle 10 pixels:

Code: Select all

"%IMG%convert" ^
  -size 50x60 xc:black ^
  ( -size 60x10 gradient: -rotate 90 ) ^
  -size 50x60 xc:white ^
  +append ^
  mask.tiff
Apply the mask to the greenRight image, making it transparent where the mask was black and opaque where the mask was white. Place the result over the redLeft image.

Code: Select all

"%IMG%convert" ^
  redLeft.tiff ^
  ( greenRight.tiff mask.tiff -compose CopyOpacity -composite ) ^
  -compose Over -composite ^
  out.tiff
There is a problem: the central portion is too dark. This is because we have worked in sRGB space, but RGB is a better choice.

Code: Select all

"%IMG%convert" ^
  ( redLeft.tiff -colorspace RGB ) ^
  ( greenRight.tiff mask.tiff -compose CopyOpacity -composite -colorspace RGB ) ^
  -compose Over -composite ^
  -colorspace sRGB ^
  out2.tiff
You can extend this technique to any number of slices. Obvious improvements are possible, such as applying the colorspace adjustment to the mask instead of the photos.
snibgo's IM pages: im.snibgo.com
cowanrg
Posts: 3
Joined: 2012-12-24T12:54:18-07:00
Authentication code: 6789

Re: taking small slices from multiple images and blending th

Post by cowanrg »

I think you took me too literally, sorry. what I posted was merely an example, but I'll be using actual photographs. the same thing can be accomplished in photoshop with a layer mask with a gradient to blend the layers.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: taking small slices from multiple images and blending th

Post by snibgo »

cowanrg wrote:I think you took me too literally, sorry. what I posted was merely an example, but I'll be using actual photographs. the same thing can be accomplished in photoshop with a layer mask with a gradient to blend the layers.
You can use these techniques for any images, including actual photographs.
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: taking small slices from multiple images and blending th

Post by anthony »

Also see...
IM Examples, Photo Handling, Overlapping photos
http://www.imagemagick.org/Usage/photos/#overlap
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
cowanrg
Posts: 3
Joined: 2012-12-24T12:54:18-07:00
Authentication code: 6789

Re: taking small slices from multiple images and blending th

Post by cowanrg »

anthony wrote:Also see...
IM Examples, Photo Handling, Overlapping photos
http://www.imagemagick.org/Usage/photos/#overlap
THAT'S exactly what I'm looking for, thanks! I'll give that a try.
Post Reply