Subject opacy/transparency when stacking pictures.

I am trying to stack several pictures -of the same place, from the same spot- with different subjects that are present only during a short period of time. Hugin allows me to stack a very limited number of images and because of this the subjects appear transparent.
This is an example of what is happening. Three subjects (let’s say the lenses are people) at the same place (let’s say the table is a park).

I am assuming this is because each subject (lens) is 1/3 of the resulting picture and my uneducated guess tells me I have to use several images of the same subject at the same place, but I can only fit 1,2 or 3 pictures of each (3,6 or 9 pictures in total) in the black area. If I use more than 9 images I can’t see them and the result is garbage.

I am doing the following:
*Click on Load Images (that are then shown in the black area)
*Select Lens Type (Equirectangular seems the logical choice)
*Click on Align (wait for the assistant to run)
*Click on Create Panorama
*Select the Exposure Fused From Stacks box
*Switch to .jpeg
*Save again
*Wait while it stitches

Should I be using more than four images of each subject?

How can I work with 20 or 30 images if they are crammed in the black area and are indistinguishable?

How can I make the subject appear solid and not like ghosts?

I am willing to try doing this on rawtherapee, darktable, digikam or other software. Hugin has been what I use for this because I accidentally found this feature while trying to stitch a panorama.

Have you tried using blend masks? I’m not 100% sure I understand what you’re trying to accomplish, but seems like that’s what you’d want to use. Have a look here for more info: Hugin tutorial — Blend masks

As @ashurbanipal said, I think you should draw masks around the subjects to remove, and choose “exclude” for the type of mask.

And if you camera is stable and shows no movement at all, a simpler solution would be to use ImageMagick or G’MIC to median blend as many images as you want. But if several subjects pass in the same area more than half of the time, you’ll probably get ghosting

If you want to go a slightly different route, use hugin’s align_image_stack to align all of your shots. As @sguyader suggested, use imagemagick or gmic to median blend the image. If you want the people still in the shot, grab the median blended image (@patdavid has written about that here: ) and all the layers, bring them into gimp, and paint back in the people you want using a layer mask.

1 Like

Hugin use average_stacking by default. But Hugin can do median_stacking as well.

I guess median_stacking is not suitable for this task.

I did this task with Hugin masking.

Differences in background colors and shadows appear around the center lens

  1. You should use “align image stack” as feature matching settings.
  2. In the second video, the mask type looks like it is set to “Include region”, you should set it to “Exclude region” instead.
  3. A complication might come from the size of the objects you want to exclude, and the size of their shadows.

I’ll give it a try.

I saw that in the images given in the example, the camera has moved, so “align image stack” is not possible. Also, the exposure, white balance and focus point change between images, so a perfect blend with just image removal is not possible.
However, by using masks set to “exclude region” the result is not so bad, using “Combined stacks” → “Exposure fused stacks” in the stitcher tab:

If the images were homogeneous in exposure, WB and focal point, the result would be perfect (there’s some “focus breathing” which make the control points matching and image remapping imperfect I think).

C8H10N4O2Montreal asked:
“How can I make the subject appear solid and not like ghosts?”

So why Exclude region sguyaderSebastien Guyader ?

I was literally just thinking about this last night for some reason.

I was going to try and play with an idea in a bit that will hopefully address this concern directly.

On a side note, you won’t get a good effect that you’re looking for because the depth of field is so shallow and different between shots. That is, the backgrounds won’t match at all - it’s out of focus in varying degrees between the images (as @sguyader already mentioned).

If you were going to re-shoot the stack of images, I’d suggest keeping the settings the same between images so you don’t have this problem.

I’ll report back after I shoot some quick images to test this with.

Maybe I didn’t understand the OP, I thought he wanted to sort of “clone out” the subjects that have moved between frames, to get just the scene without subjects, hence the “exclude region” mask.
Of course if he wants the opposite, i.e. to keep all the subjects, he need an “include region” mask.
@C8H10N4O2Montreal could you please clarify what you want obtain as result?

Ok, I sort of accomplished what I wanted using Imagemagick.

I used the first 10 seconds of this video of birds in flight as a test source material:

I wanted to composite multiple frames from this video to highlight the path of the birds into a single image. So here’s what I accomplished:

My thought process for this was:

  1. Dump every N video frames to use as my test images.
  2. Isolate a background to use (using a mean blend) that is static.
  3. Mask each of those frames to only get the difference with the background I generated from step 1).
  4. Combine all of the masked frames and composite them over the background.

Dump Frames

(This is un-necessary if you already have discrete images to use).

I use ffmpeg to dump every 20th frame as an image:

$ ffmpeg -i INPUT.mp4 -vf "select=not(mod(n\,20))" -vsync vfr -t 09 %05d.png

-vf lets me select every 20th frame.
-vsync keeps the framerate in sync
-t lets me choose to only use the first 09 seconds of video
%05d.png outputs the frames as png files auto-numbered to five places

Isolate a background

Because the background is relatively static I can generate a clean background by just doing a quick mean blend of all the images:

$ convert *.png -evaluate-sequence mean background.png

I could have used a median blend also, but this is fine for this example (those ghosted bird images are going to have solid birds over them shortly. :slight_smile:

Mask each frame to isolate the birds

This is a little tougher.
Basically, I have a background image, and I want to go through each of my frames and subtract the background from the image to leave only the birds.
The magic (hah!) is using an imagemagick command like this:

$ convert 00001.png background.png -compose ChangeMask -fuzz 10% -composite maskedout.png

Take one of the frames and the background image, compose them using ChangeMask with some level of fuzz, then composite the result to an output with alpha.

I had to adjust the fuzz value to tune the isolation of the birds in the sky. This gives me something like this:

Once I had the parameters how I liked them, I could just run a simple loop in bash to run this against all the images at once and output them into a new directory:

$ for file in 000*.png;do convert $file out.png -compose ChangeMask -fuzz 10% -composite tmp/$file;done

(Seriously, I think I’d go insane trying to mask each of those birds by hand!)


Finally, I just needed to combine all of these images over the background I originally made:

$ convert 000*.png -background none background.png -compose dst_over -flatten output.png


Instead of the sequence

  • Isolate a background
  • Mask each frame to isolate the birds
  • Combine!

(running 3 commands in a loop), you could also try
hugin_stacker --mode=median --mask-input --multi-layer-output --output=output.png 000*.png
from the Hugin package, which should do something similiar.
Now it remains to flatten the layers.

Maybe in this image sequence also hugin_stacker --mode=darkest --output=output.png 000*.png delivers a similar result.


Thank you, ashurbanipal… the masking technique was the answer.

Thanks. Masking was the answer. The Hugin way was how I did it (ImageMagick is still something I don’t get a grip of).

Thank you for taking the time to make the videos, yteaot.
I added/skipped steps, but the result I wanted was possible because of your suggestions.

You are right. The camera might have moved a bit… while placing or removing one of the lenses. I wanted to post the question and imgur link before going to bed and all was done in a rush.

The second video posted by yteatop showed me how to do it. The camera might have moved a bit… while placing or removing one of the lenses. I wanted to post the question and imgur link before going to bed and all was done in a rush. The images won’t be shot again… they were just a quick resource for the question.

You are right. Include Region had to be selected. It took me a while, but I got it.
What I was looking for was a way to have the same subject on different places of the -same- picture.
Using masks in Hugin and then selecting Include Region did the trick. Thanks.

Thanks for such a thorough reply. I was only working with three images and my knowledge of the terminal is pretty basic. In the end I needed to mask images on Hugin, select Include Region and the Stitch.