# Limit to the number of images one can stack with alpha blending?

I would like to show high level structural similarities between a huge number of images with the same dimensions.

Ideally I'd like to stack them all on top of eachother and set the alpha of each to 1/n, where n is the total number of images in the stack, to allow users to see the high level accumulation of structural similarity visually.

My question is: is there a limit to the number of images one can stack in this way? If so, does anyone know what the perceptual or mechanical limit is? Any thoughts others can offer on this question would be most appreciated.

• Why dont you use the image stack feature? Also by 1/n do you mean that if i have 3 images that each has a alpha of 33% or that bottommost has 100 then next 50 and topmost is 33. Only the later actually blends a average (again use imagestack its faster to set up and has less rounding errors) Mar 18, 2019 at 6:19
• I've since learned that to get proper alpha blending one must set each image's alpha differently. In a stack with two images, top image has alpha 0.5, bottom has 1.0. In a stack with three images, top image has 0.33, middle has 0.66, and bottom has 1. So each image gets alpha idx/n, where idx is the images index position (1 = top, n = bottom), and n is the number of images in the stack. Mar 18, 2019 at 15:31
• In 8-bit each channel has 256 steps (0-255). So my (maybe naive) logic tells me that in 8-bit, you can stack 256 "1-bit" images (only black and white pixels) without loosing data. If your images are 8-bit and thereby already potentially contains 256 levels of data, you will loose data already when layering two images, because you need to shrink the data of each image to 128 steps. Does this make sense? Mar 18, 2019 at 16:44
• Thats odd, then for three images it would result in first image having a weight of 33% rsecond image a weight of (0.67*0.66) 44% Mar 18, 2019 at 16:44
• @Wolff well it cant be answered it really depends on the images themselves it wors well for qjite many images only if one of the images has a high entropy and images are predominately black. So its impossible to say Mar 18, 2019 at 16:50

If your aim is average then each layer needs to have a progressive value based on previous layers in the stack.

for average

``````layer no   alpha (%)
1          100
2          50
3          33
4          25
5          20
6          17
7          14
``````

And so on. Proof:

If you want to have a stack of 4 layers and each have same contribution then: At layer 2 each layer has a 50 50 because layer 2 lets half trough. At layer 3 layer one is 33 and layers 1 and 2 contribute 67% of 50 Which is 33% within rounding error. At layer 4 layer layer 4 has 25 % and layers 1-3 have 75% or 33 which again is 25% withing rounding error.

Now the problem with this is that for many layers its tedious to set up. But also there is a significant source of rounding errors happening at each layer computation.

Now since you have tagged this Adobe Photoshop, theres a easier and less rounding prone way. What you do is:

1. You select the layers you want to average in the layers panel.
2. Right click on the layers palette and choose make Convert to smart object
3. Now there is a special function in Layer → Smart Objects → Stack Mode → Mean

It also has other nifty statistical tools. Benefit of this is that if you want a eliminate you can just hide it and it does not partake in the stack. Also it does less rounding errors. But more importantly you canb use the super useful median and min/max. (although the others have their uses for scientific imaging)

How many can you stack? Well it depends on the images and how they overlap it is possible that a average of a couple of hunred images can tell you something, i have used such images. But more likely blending thisway more than 12 images wont give you much.

• @duhaime uups theres a error you should be using mean for average not median. Mar 18, 2019 at 20:13