What's new

Brush opacity and feathering algorithms - just a discussion.


Tony Bowman

Well-Known Member
Messages
68
Likes
87
Opacity is 'fill' level for brush. So a brush at 100% opacity will 'fill' at 100%.

So why then, does it take three brush strokes to reach maximum fill at 50% opacity (when logic says it should take 2), and seven brush strokes to reach maximum fill at 25% opacity (when it should take 4)?

Similarly with feathering. A specified level of pixel feathering does not match the end result (see screenshot). I've tested this on numerous trials from 1 to 10 pixel feathering and counted the number of pixels affected - there seems to be no correlation between the specified pixel feather and the result. So, for example, the 2 pixel feather, on the straight edge, affects 7 pixels, and the 4 pixel feather, affects 12 pixels.

I find these to be slight annoyances, especially on the feathering, but I'm more interested to know how and why this should be, and if anyone else has investigated it? I'm guessing it's something to do with the workings of Photoshop? It would be nice to find some sort of equation to do away with the frequent trial and error of brush strokes and feathering.

Untitled-2.jpg

ps. I'm using CS5.
 

fredfish

Guru
Messages
887
Likes
1,247
Bottom line is I don't know - but an interesting question. Looking at the feathering question, take your second example and look at the pixel I have highlighted there is feathering 2 pixels either side of the selected pixel. So I would assume when is says 2 pixels feathering that it means 2 pixels either side of the central point.

Untitled-2.jpg

I am also going to suggest that the opacity issue is perhaps that the 50% is cumulative rather than absolute. Not sure about this one because then logic would suggest that 100% would never be reached.

As I said - interesting question :)

Cheers

John
 
Last edited:

thebestcpu

Guru
Messages
2,032
Likes
1,878
Hi Tony,
Fredfishe's summary is accurate. Here is a more specific answer.

Think of drawing with opacity in these terms.

If you are drawing with 50% opacity, each brush stroke allows 50% of the lower level through and 50% of the brush color..
So it ends up getting you another 1/2 way there geometrically i.e. first stroke 50%, next stroke is another 1/2 way there to 75%, then 87.5%, then 93.75%, etc.

With 25% opacity, then 75% is let through from the previous stroke or lower layer and 25% of the brush color so the progress would be 25%, 43.75%, 57.8125, 68.359%, 76.27%, 82.2%, etc

That's the math involved. If you have more questions or want more details just ask.



As for feathering, that is a different situation. This is basically the same as a Gaussian blur. If you set a Gaussian blur to 10 pixels, this is just the first sigma of a Gaussian curve and the blur continues out indefinitely in mathematics yet in Photoshop only to 2.5 sigma. So if you pick a feather of 10 pixels, it will be a Gaussian blur both out in in by 25 pixels.

That is both my understanding and experience yet is room for error on my part.

Hope that helps

John Wheeler
 

Tony Bowman

Well-Known Member
Messages
68
Likes
87
Ooh... that is really interesting! I knew it was probably going to be something weird!!! Lots here to think about... Flow is another one that fascinates me: I was able to paint a single stroke at (apparently) 100% whilst having flow set at 25%. Brush spacing has interesting influences on flow. But armed with this technical info, I shall go do my research. First stop though is google for 'Gaussian curve' and 'sigma'. Those terms are new to me. I always wondered how Gaussian blur got its name. Thanks for both for these really helpful answers.

Where I'd like to get to with all this, is be able to determine exactly the blur settings for any given image based on it's pixel size (and flow/opacity based on what I want) without the trial and error element. That said however, experience by itself is largely overcoming this; but all the same, I'm a closet scientist - I like to know how things work :)
 

Rich54

Guru
Messages
1,195
Likes
2,336
Adding my two-cents to the Opacity/Flow discussion...

As John Wheeler says, if you set Opacity to 50%, the brush strokes cumulatively give you 50%, then 75%, then, 87.5%, etc. It theoretically never reaches 100% no matter how many brush strokes you apply, but as a practical matter your eye can't really tell the difference once you reach 95% or so. The mathematical term for this kind of thing is "Asymptote". An asymptote is a mathematical curve that approaches a certain number without ever reaching it. An example would be the graph of the formula Y = 1 divided by X. The greater X becomes, the closer Y gets to zero, but you never actually arrive at zero even if X = 50 trillion gazillion.

In Photoshop, the Flow setting is additive. I've never actually tested it, but if you set the Flow to 10% then each stroke adds 1/10th of the strength of the color and it should take 10 strokes to achieve the full color. I use the Flow setting all the time for dodging & burning or to gradually apply a color or an adjustment layer. I'll set the flow to something very small like 5%, so each individual brush stroke gives you a barely perceptible change and you get a lot of control over the outcome.

Rich
 

thebestcpu

Guru
Messages
2,032
Likes
1,878
In Photoshop, the Flow setting is additive. I've never actually tested it, but if you set the Flow to 10% then each stroke adds 1/10th of the strength of the color and it should take 10 strokes to achieve the full color. I use the Flow setting all the time for dodging & burning or to gradually apply a color or an adjustment layer. I'll set the flow to something very small like 5%, so each individual brush stroke gives you a barely perceptible change and you get a lot of control over the outcome.

Rich
Rich, my understanding (though limited) is slightly different on the flow control for brushing.

My understanding is that the flow level works exactly mathematically like the opacity level except that each step occurs with each successive daub that the paint brush sets down within a single stroke.

The maximum value that can be achieved with the flow control in a single stroke is the limit set by the opacity control. Subsequent strokes work similarly i.e. geometrically and not additive (10 daubs at 10% won't add up to 100% through it is close on the first few daubs)

Another tidbit is that the flow opacity and flow control are multiply with each other. The first daub put down with opacity at 50% and flow control at 50% is 25%.

So I think in terms of the flow control (multiplied by the opacity control) sets the increment percent that the brush can change the color with each daub within a single stroke and the max within a stroke is limited by the opacity control level).

To go higher is simply done by doing additional strokes with the steps again being geometric starting with a new base value from the previous stroke.

The math if more academic because it all becomes natural through experience with use as with any other skill. It just may help as a starting point with what to expect.

That is at least my understanding

John Wheeler
 

Rich54

Guru
Messages
1,195
Likes
2,336
John, thanks for the clarification. Years ago I read a long article on this topic but I must have mis-remembered it.
 

thebestcpu

Guru
Messages
2,032
Likes
1,878
John, thanks for the clarification. Years ago I read a long article on this topic but I must have mis-remembered it.
Hi Rich, I am not "the" expert. Just sharing my observations and therefore subject to error and inaccuracies as well.

One thing I did do to satisfy my understanding of the feathering being Gaussian (or as is often called a Normal Curve), I created a Black to White edge with a 10 pixel feather and plotted the black to white transition curve and plotted that against a cumulative Normal Curve. It was a real close match confirming my understanding.

Here is the link to a Normal/Gaussian curve, the math, and what the CDF or Cumulative Distribution Function or the Normal curve: https://en.wikipedia.org/wiki/Normal_distribution

Following is the Graph of the CDF curve with a sigma of 10 vs the black to white 10 pixel feather transition in PS. This is only to satisfy those such as Tony Bowman and myself where math gives comfort :)

PS Feather vs CDF .png
 

Top