PJSR: Blend script

mikertx

Well-known member
I was surprised that I could not find this script already in the forums so I decided to have a go.  The "Blend" script will blend two images using any of the blending modes whose PixelMath formulae were detailed in this posting,
  http://pixinsight.com/forum/index.php?topic=2409

I have also added a variable opacity slider to allow for adjustment of the amount of mixing of the blended image with the bottom image.  This led to the addition of the "Normal" blend mode (simple percentage mixing of the two images) to those enumerated in the posting, namely,

  Darken
  Multiply
  Color Burn
  Linear Burn
  Lighten
  Screen
  Color Dodge
  Overlay
  Soft Light
  Hard Light
  Vivid Light
  Linear Light
  Pin Light
  Difference
  Exclusion

There is nothing here that you can't already do with Pixel Math but maybe it will prove to be a time saver for some.  I have attached the script and a screenshot of the popup.

Mike
 

Attachments

  • screen.jpg
    screen.jpg
    49.3 KB · Views: 284
  • Blend_v1.0.zip
    2.7 KB · Views: 501
Good work Mike. Thanks for a nice and useful script.

I would add also the missing arithmetic operations:

Add
(Multiply - already included)
Subtract
Divide

and also the flat fielding operation:

IMG1*mean( IMG2 )/IMG2

where IMG2 acts like a flat frame. There are other useful ones that we probably can figure out with a bit of brainstorming.
 
Hi

As I am photoshop useless , other than the obvious what are the real world use of the blend modes  >:D

I did see the little demo in the other thread , but give me some real use ideas so dumbo here can understand  :-[

Kind regards Harry
 
Harry,

I've never used most of them either but one example that comes up often in astrophotography is to make a copy of an image, use high pass filtering on it and then blending it back with the original using "overlay" blending mode.

Juan,

I'll add these other operations.  I have some other improvements in mind as well.

Thanks all for the kind remarks,
Mike
 
yes the flat fielding op would be very nice, since i find myself having to quickly flatten single frames while i'm evaluating my pointing...
 
Hi Mike!
Great tool.
I like it because it adds a slider to selected PixelMath functions.
And additional PixelMath functions can be added very simple.

To find out what is the best percentage with the slider it woud be nice
when the script stays with the selected parameters for another and another try with percentage etc.
Finally then to exit with an exit button. ("OK" should not end the script)

I managed somehow to remove the "break" in your script so i can run and test the different results without
starting the script again and again. However my exit needs to be more elegant - have no idea with scripts how to
exit...

Thanks for your work and your help if possible.

aloha
gerald
 
oldwexi said:
Hi Mike!
To find out what is the best percentage with the slider it woud be nice
when the script stays with the selected parameters for another and another try with percentage etc.
Finally then to exit with an exit button. ("OK" should not end the script)

gerald

+1
 
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,
 
Back
Top