I am replying to this very old message just in case anyone should come here as I did and find the old version of the Blend.js script. Blend v1.0 handles some things incorrectly- specifically the Screen blending mode. Later versions of Blend apparently fix this (good job). I did not find mention of later versions or anyone fixing the issue in forum posts.
I spent a good hour trying to understand what was going on. The formula is correct- but I finally noticed in the process console window that the script RESCALES the result. This is the (subtle) problem and not correct. Maybe very old attachments like scripts can be cleaned occasionally? Version 3.0 truncates values as expected.
___
Here is what I wrote in an e-mail to try to understand the issue:
I think I found something strange...
Here is the formula for the Photoshop Screen blending mode (Pixel Math):
a=0.7;
top=Mean_m27_H_alpha;
bottom=Mean_m27_DBE_Deconvolved;
a*(1-(1-top)*(1-bottom)) + (1-a)*bottom
Symbols, a, top, bottom
This will blend these two images together. However... if you use the Screen Blending mode in the script that Mike Reid wrote (Blend) it gives you a different result. Looking at the Processing Console, the formula is CORRECT. However the implementation is not (in my mind).
This blend mode should be symmetric in that the order of the layers (which image is top or bottom) doesn't matter. To quote from wikipedia:
" With Screen blend mode the values of the pixels in the two layers are inverted, multiplied, and then inverted again. This yields the opposite effect to multiply. The result is a brighter picture.
f(a,b)=1-(1-a)(1-b)} f(a,b)=1-(1-a)(1-b), where a is the base layer value and b is the top layer value."
This mode is symmetric: exchanging two layers does not change the result. If one layer contains a homogeneous gray, Screen blend mode is equivalent to using this gray value as opacity when doing “normal mode” blend with white top layer."
Note that homogeneous gray values act as an "opacity." This is an important part of the behavior for Screen. When pixels are black in one image- the result is the value of the OTHER image. ie Screen(top = 0, bottom = 0.5) = 0.5. This behavior allows you to create a threshold for the blend by making black pixels and it is VERY powerful.
The script however takes an extra step that breaks this result. It RESCALES the result. This breaks the symmetry and also breaks the opacity and black pixel behavior. So it does not work like the true Photoshop blending mode.
Have I gone down the wrong road- is my logic unsound?
Thanks,