How do I manually stack photos for an equal average using given opacity levels?

  • Thread starter LightningInAJar
  • Start date
  • Tags
    Photos
In summary: Otherwise, you will end up with some empty space. The given method is more flexible as it can be used with any number of layers and they can be different sizes and shapes. The math works by dividing the opacity of each layer by the total number of layers and then stacking them on top of each other. This ensures that each layer contributes equally to the final image.
  • #36
DaveC426913 said:
But why?? Its mystifying what you are trying to do.

What is it about the last 2 dozen posts of tutelage that makes you not want to do it this way?
What do you mean? Doesn't this method show that each photo is equally represented? That is what I wanted to do rather than take anyone's word for it.
 
Physics news on Phys.org
  • #37
LightningInAJar said:
What do you mean? Doesn't this method show that each photo is equally represented? That is what I wanted to do rather than take anyone's word for it.
I had hoped I'd done that in post 22.

Still, I'm not convinced your math is sound, even if you appear to arrive at a satisfactory answer. You start off multiplying by .8 and then later on you switch to multiplying by .75. (I guess you implicitly follow up with multiplying by .667 and then by .5 , but how do you know/prove those are the right numbers?)
 
  • #38
DaveC426913 said:
I had hoped I'd done that in post 22.

Still, I'm not convinced your math is sound, even if you appear to arrive at a satisfactory answer. You start off multiplying by .8 and then later on you switch to multiplying by .75. (I guess you implicitly follow up with multiplying by .667 and then by .5 , but how do you know/prove those are the right numbers?)
Your post at 22 appeared to be mostly visual which relies on healthy retinas which I don't have. I assume my process works because I ended with all layers having 20% left. Would different numbers result in the same outcome?
 
  • #39
LightningInAJar said:
Your post at 22 appeared to be mostly visual which relies on healthy retinas which I don't have. I assume my process works because I ended with all layers having 20% left. Would different numbers result in the same outcome?
It doesn't really work because, in general, you don't have those percentages available for you. What do you do for 6 layers instead of 5? Or 130 layers for those astrophotographers like me who stack lots of images together?

A better method is the one shown in post #25, where each layer has an opacity equal to 1/n, where n is the layer number.
Take a look at post #33 again where I went through n=2 and n=3.
 
  • #40
LightningInAJar said:
Your post at 22 appeared to be mostly visual which relies on healthy retinas which I don't have. I assume my process works because I ended with all layers having 20% left. Would different numbers result in the same outcome?
But there is no mystery in those numbers. The opacity of each layer ##L_n## is ##\frac{1}{n}## in a percentage form.
Question: Why does that work?
Answer: It works because the n'th layer gets 1/n opacity and leaves (n-1)/n opacity for all the lower layers. That (n-1) multiplier cancels the 1/(n-1) opacity for the (n-1) layer.
##\frac{1}{n} L_n + \frac{n-1}{n} ( \frac{1}{n-1} L_{n-1} + \frac{n-2}{n-1} (\frac{1}{n-2} ... ##
is the same as
##\frac{1}{n} L_n + \frac{1}{n} ( L_{n-1} + (n-2) ( \frac{1}{n-2} ... ##
So the (n-1) factors are gone. Likewise, the (n-2) factors all cancel and are gone. Likewise (n-3). etc. etc. etc.
After all the canceling is done, only the ##\frac{1}{n}## of the top layer remains to multiply all the layers equally.
 
Last edited:
  • Like
Likes Drakkith
  • #41
Drakkith said:
It doesn't really work because, in general, you don't have those percentages available for you. What do you do for 6 layers instead of 5? Or 130 layers for those astrophotographers like me who stack lots of images together?

A better method is the one shown in post #25, where each layer has an opacity equal to 1/n, where n is the layer number.
Take a look at post #33 again where I went through n=2 and n=3.
If I had 6 layers instead of 5 I would simply multiply everything by .83 on top of everything before that. That is 5/6ths.
 
  • #42
LightningInAJar said:
If I had 6 layers instead of 5 I would simply multiply everything by .83 on top of everything before that. That is 5/6ths.
Your method requires several more steps than the method we outlined, but different strokes for different folks.
 
  • #43
LightningInAJar said:
If I had 6 layers instead of 5 I would simply multiply everything by .83 on top of everything before that. That is 5/6ths.
IMO, the only reason to do this is to convince yourself that the final result gives equal opacity to all the layers. Your approach only does that for one example at a time and it seems like a coincidence each time. You can add a 6'th layer and show that it works for 6 layers, but does that make you confident about WHY it works enough to say that it would also work for 15 layers? Or 115 layers? I think that the only insight you get from your approach is that it worked "by magic".
There are better ways to approach it that are much more convincing that it always works for any number of layers (for instance posts #31 and #40). That is what we keep trying to convince you of.
 
Last edited:
  • #44
I have trouble understanding your methods. I am not good at reading math notations. And convincing myself that it does equal for all images is what I care about. If I needed to stack much more than 20 images I would probably use an auto tool anyway. The manual method doesn't work with anything less than whole number percentages so I likely could only screw it up with those higher numbers. Any simple formula that is less multi-step that represents the concept?
 
  • #45
Sure. Add each pixel value together and then divide by the number of photos. In other words, add every (1,1) pixel from each image together and divide by the number of images. Then do the same for all (1,2) pixels, all (1,3) pixels, etc.
 
  • #46
Following @hutchphd's post #25 which recommends using induction:
We know that for one level, it is trivially true. 1/1 (=100%) is the right opacity for one level. For opacities, we will use fractions instead of percentages (e.g. 100%=1, 50%=1/2, 33%=1/3, 25%=1/4, 20%=1/5, etc.)

Suppose that for n levels, we have that our method gives opacities of 1/n equally for each level. Call it the ##mergedNLowerLevels = 1/nL_n+1/nL_{n-1}+...+1/nL_1 = 1/n(L_n+L_{n-1}+...+L_1)##.
(Example of 5 levels: ##1/5L_5 + 1/5L_4 + 1/5L_3 +1/5L_2 + 1/5L_1 = 1/5(L_5+L_4+L_3+L_2+L_1)## call this the ##merged5LowerLevels##)
Now let's add one more level, ##L_{n+1}##
(Example add level ##L_6##).
Our method is to give an opacity of 1/(n+1) to the new level, ##L_{n+1}##, and n/(n+1) to the ##mergedNLowerLevels##
##1/(n+1)L_{n+1} + n/(n+1) (mergedNLowerLevels)##
(Example: ##1/6L_6 + 5/6 (merged5LowerLevels)##).
Because we supposed that the method worked for that merging of n lower levels, we have
##mergedNLowerLevels = 1/n(L_n + L_{n-1} + ... + L_1)##
(Example: ##merged5LowerLevels=1/5(L_5 + L_4 + L_3 +L_2 + L_1)## )
So with the new level we have ##1/(n+1)L_{n+1} + n/(n+1)(1/n(L_n + L_{n-1} + ... + L_1))##
(Example ##1/6L_6 + 5/6(1/5(L_5+L_4+L_3+L_2+L_1)## )
Canceling the ##n## multiplier with the ##1/n## gives ##1/(n+1)(L_{n+1}+L_n+L_{n-1}+...+L_1)##
(Example: Canceling the 5's in ##5/6(1/5 ...)## gives ##1/6(L_6+L_5+...+L_1)##
So our method gives equal opacities with the added level.
With this, we know that our method works for 1, 2, ..., n and n+1 and then n+2 and then n+3, ... all the way up to any number of layers.
 
Last edited:
  • Like
Likes hutchphd
  • #47
LightningInAJar said:
Any simple formula that is less multi-step that represents the concept?
Again, yes.

On = 100/n
Where
O = opacity (as a %)
n = layer number (bottom layer being 1)
 
  • Like
Likes hutchphd
Back
Top