Topic: Layers in Image Analyzer

I have been working on implementing some basic support for layers in Image Analyzer - trying to find a way to do it without having to rewrite the entire application.
If anyone is interested you are welcome to help me test it in the latest beta version (available at http://meesoft.logicnet.dk/support/view … ?id=3237).

A layered image is basically just a combination of existing open images using either mask blend, add or subtract operations. Note that a mask layer always applies to the underlying image layer.
Manipulations from the Operations menu can be applied to the individual images and the layered image will be updated accordingly. Painting can be done directly on the layered image and will be transferred to the active layer.
To add layers to an open image you can use File | New layered image.

I have put a simple example here: http://meesoft.com/Analyzer/Examples/LayersExample.zip (from Otavalo, Ecuador)
It shows how a blend mask layer can be used to simulate out of focus blur on the background of a picture.

Suggestions and error reports to the layer support in IA is welcome in this forum thread.

Michael Vinther

> software developer <


Re: Layers in Image Analyzer

Wouldn't adding Add and Subtract blend modes to the Fade options do the same thing?

Are you going for a full implementation of layers with a range of blend modes? Will you have the ability to create a duplicate layer?


Re: Layers in Image Analyzer

You could achieve some of the same effects with the Fade or Combine features but the nice thing about working with layers is the continuous updating of the result as you edit the layer images or e.g. paint in the blend mask - like I painted the mask for the example above.
Another example: http://meesoft.com/Analyzer/Examples/LayersExample2.zip (from Abisko in northern Sweden)
Here I have split the image into high and low frequency layers. Try to activate the HP layer and edit the curve like in the image below (a bit flat around 64) and and see what happens to the noise in the sky.. Interactive editing with immediate feedback makes it much easier to get the curve right.

Which other blend modes would you suggest? I'm not very experienced in working with layers myself as I use IA for all of my photo editing smile

Michael Vinther

> software developer <


Re: Layers in Image Analyzer

PhotoFiltre 7 is a free editor that has a pretty standard implementation of layers with blend modes and an opacity slider and a visibility checkbox.  http://www.photofiltre-studio.com/pf7-en.htm 

I guess for masking you only need add and subtract. For blending two images the most useful are Normal, Lighten, Darken, Multiply, Screen, and Soft Light. You already have normal (All), lighten and darken in the Fade option.

It would be nice to also have these in the Fade option.

1. Add

2. Subtract

3. Multiply blend mode : A×B (Active Layer multiplied by Background Layer).

4. Screen blend mode : 1−(1−A)×(1−B) (A inverted multiplied by B inverted, and the product is inverted)

Multiply darkens the image, and Screen lightens it. Fade the Opacity to get the exposure you want.

5. Soft Light increases contrast. The formula is more complicated.

The formulas for a lot of blend modes can be found here: http://www.simplefilter.de/en/basics/mixmods.html


Re: Layers in Image Analyzer

I can see that adding layer masks would be useful. Add and Subtract would be the only blending modes you would need for that. You can set the opacity with the numbers 0-255 as you have done. I haven't figured out yet how they work in the beta IA.

The All, Lightest, and Darkest pixels blending modes you already have work great for me. I can usually get just what I want with them. I seldom use any other photo editor because the Fade option in IA makes blending so easy and fast. And clone painting from one image to another is just like using the eraser tool in images with layers.

If you think it worthwhile, I'd like to see Add and Subtract modes in the Fade option. They would work better than Lighten and Darken for border masks and texture masks.


Re: Layers in Image Analyzer

Thanks for the reference Jim.
I must say that can't really guess the practical applications for all these modes in Layers and Fade. Of cause I could easily add more, but I would like to understand what they would be useful for.. I guess I need to do some googling...

Perhaps I will also add support for a user defined formula.

Michael Vinther

> software developer <


Re: Layers in Image Analyzer

Hi Michael,

Here's how I use them with my AAA Options plugin for self-blends.

1. Multiply to darken and overexposed image. It will usually darken too much, so I just fade the opacity.
2. Screen to brighten an underexposed image. Fade as needed.
3. Soft Light to add contrast.

In AAA Blender I use these a lot when adding a new layer.

4. Overlay adds even more contrast. It's good for adding a grunge or texture or color layer.
5. Add and Subtract for grayscale masking.

You can try AAA Options and AAA Blender 8bf plugins. They have all of these blending modes.
These are at 8bf.net if you want to see what the blend modes do in IA.

A user defined option would work for the simpler modes. Soft Light screens the darker pixels and Multiplies the brighter pixels -- above 127 and below 128. I don't know if that could be put into one formula. It would make Difference mode easy.



Re: Layers in Image Analyzer

Thanks for the tips. For a start I have added a Custom expression mode in the Fade dialog and a few more layer types in the latest beta.
It is possible to enter complex expression like that for Soft light, but of course you need to do it manually for now. I'm considering to have some way of storing multiple expressions.

Michael Vinther

> software developer <


Re: Layers in Image Analyzer

I just looked at the blending formulas a bit. Basically soft light is just an s-curve if you apply it on a duplicate of the background layer. You can plot it in the Expression Evaluator in IA by copying in this:

plot(if(a<0.5, (2*a-1)*(a-a^2)+a, (2*a-1)*(sqrt(a)-a)+a), a)

- and setting the range of the plot to 0 to 1.
I guess you can achieve the same by increasing the contrast in the color curve dialog.

Michael Vinther

> software developer <


Re: Layers in Image Analyzer

do you plan later a bigger toolbox for Painting on the left?


So far the existing painting tools have been sufficient for me. Anything in particular you miss?

Michael Vinther

> software developer <


Re: Layers in Image Analyzer

Great start, Michael. I got three blend mode formulas that work.

Multiply mode is p1*p2/255

Screen mode is 255(-255-p1)*(255-p2)/255

Difference mode is abs(p1-p2)/2

Maybe it should be 256 instead of 255. I got those formulas from the FilterMeister documentation. They used 255.

The contrast modes are more complicated. I don't know how to translate them to IA. Here they are.

Soft Light is a<128 ? 2 * scl(b,0,255,64,192)*a/255 : 255-(2*(255-scl(b,0,255,64,192))*(255-a)/255)

Overlay is a<128 ? (2*a*b/255) : 255-2*(255-a)*(255-b)/255


Re: Layers in Image Analyzer

Is there an equivalent to if-then-else in Custom expression?

Something like IF p1<128 THEN p1*p2/255 ELSE 255(-255-p1)*(255-p2)/255 would work for Soft Light.


Re: Layers in Image Analyzer

I actually gave you the solution in the post above smile - you can see all supported functions in Expression Evaluator in the Help menu.

The Soft light formula from http://www.simplefilter.de/en/basics/mixmods.html should be translated to

if(p1<128, (2*p1-255)*(p2/255-(p2/255)^2)+p2, (2*p1-255)*(sqrt(p2/255)-p2/255)+p2)

in IA's Fade dialog. All of the extra scaling of course comes from IA working on 8bit pixel values in the range 0-255 where the formulas on the page are in normalized pixel values in 0-1.

Or, for layers with an opacity parameter v you could use

(p1*(255-v) + if(p1<128, (2*p1-255)*(p2/255-(p2/255)^2)+p2, (2*p1-255)*(sqrt(p2/255)-p2/255)+p2)*v)/255
Michael Vinther

> software developer <


Re: Layers in Image Analyzer

Thanks, Michael. Now I have it.

p1*p2/255 for Multiply

255-(255-p1)*(255-p2)/255 for Screen

if(p1<128, (2*p1-255)*(p2/255-(p2/255)^2)+p2, (2*p1-255)*(sqrt(p2/255)-p2/255)+p2) for Soft Light


Re: Layers in Image Analyzer

Overlay blend mode for Custom expression: if(p1<128, (2*p1*p2/255),255-2*(255-p1)*(255-p2)/255)