Jump to content
dmstraker

Select by saturation/saturation mask?

Recommended Posts

Is it possible to select by saturation level?

 

I'm particularly thinking of using saturation masking (if it can be done).


Dave Straker

Cameras: Sony A7R2, RX100V

Computers: Win10: Chillblast Photo with i7-3770 + 16Gb RAM + Philips 40in 4K; Surface Pro 4 i5

Favourite word: Aha. For me and for others.

Share this post


Link to post
Share on other sites

Masks are an integral concept (and done well in AP) and it's worth spending time to figure thm out. Basically, when you have two layers, a mask will block out a part of the top layer so parts of the bottom layer 'shine through'. This allows you to combine different treatments of parts of the image.

With saturation masking, you can, for example, select areas that are highly saturated and turn this down (and hence reducing the visual impact of these areas). Vibrance kind of works like this as it increases the saturation more from areas of lower saturation.

You can select by luminosity and hue, but (it seems) not saturation, which is why I asked the question.


Dave Straker

Cameras: Sony A7R2, RX100V

Computers: Win10: Chillblast Photo with i7-3770 + 16Gb RAM + Philips 40in 4K; Surface Pro 4 i5

Favourite word: Aha. For me and for others.

Share this post


Link to post
Share on other sites

I might have found an approach for this. See here:

 


Dave Straker

Cameras: Sony A7R2, RX100V

Computers: Win10: Chillblast Photo with i7-3770 + 16Gb RAM + Philips 40in 4K; Surface Pro 4 i5

Favourite word: Aha. For me and for others.

Share this post


Link to post
Share on other sites

When this thread and the tutorial with the solution were posted by  @dmstraker, back in December, I read them with interest. Around that period there were also some posts about the use of Equations in AP. As H, S and L can be derived from R, G, B as formula calculations, I thought it could be possible to build a saturation mask in this way, with Apply Image.

Details of the calculations were from Rapidtables RGB to HSL Converter

The calculations are as follows:

R,G,B = Red,Green,Blue as values in range 0 -> 1 - so divide ordinary R,G,B by 255

L(ightness) = ((Max(R,G,B)+Min(R,G,B))/2)

Delta = (Max(R,G,B)-Min(R,G,B))

S(aturation) = Delta / (1-Abs((2*L)-1))

 

Having selected the layer required, Filters -> Apply Image ->Use Current Layer as Source then tick Equations, and ensure Color Space is RGB.

In terms of SR, SG and SB,

S(aturation) = (Max(SR,SG,SB)-Min(SR,SG,SB))/(1-Abs((2*((Max(SR,SG,SB)+Min(SR,SG,SB))/2))-1))

and so set Destination R, G and B all to that value

DR, DG and DB = (Max(SR,SG,SB)-Min(SR,SG,SB))/(1-Abs((2*((Max(SR,SG,SB)+Min(SR,SG,SB))/2))-1))

 

 

Share this post


Link to post
Share on other sites

Found better approximation for saturation, using LAB mode - since LAB channels separate hue from lightness, saturation can be directly conducted from A and B channels
So select the layer required, Filters -> Apply Image ->Use Current Layer as Source then tick Equations, and ensure Color Space is LAB.
Then set 
DL = Sqrt((Sa-1.0)*(Sa-1.0)+(Sb-1.0)*(Sb-1.0))
Da = 1.0
Db = 1.0

Edited by IPv6
typos

Share this post


Link to post
Share on other sites

Still tinkering with this. On the Apply Image Equations front, in RGB space, I've tried two alternatives.

Original:

914504853_calcoriginal.thumb.png.1bdd3254e971a3add97cc0cce88a35ac.png

 

First (and I think best) is:

Duplicate layer.

DR=max(SR,SG,SB)-min(SR,SG,SB)
DG=max(SR,SG,SB)-min(SR,SG,SB)
DB=max(SR,SG,SB)-min(SR,SG,SB)

1785769066_max-mincalcDxmax(SRSGSB)-min(SRSGSB).thumb.png.328b5718ea1c83b6f26594f07132813d.png

Then invert layer and convert to mask.

This is based on the principle that 'greyness' increases when RGB vallues are closer to one another. When R=G=B, then a shade of grey is displayed. So max-min calculation gives the range.

A variant ion the above is simply to use an average, which take account of the middle value. This third value doesn't really affect grey, but it's an interesting difference to play with.

DR=average(SR,SG,SB)
DG=average(SR,SG,SB)
DB=average(SR,SG,SB)

852710450_averagecalcDxaverageSRSGSB).thumb.png.14b1f778b5668d205bab5945f2e738f6.png


Dave Straker

Cameras: Sony A7R2, RX100V

Computers: Win10: Chillblast Photo with i7-3770 + 16Gb RAM + Philips 40in 4K; Surface Pro 4 i5

Favourite word: Aha. For me and for others.

Share this post


Link to post
Share on other sites

A statistical parameter which would have a value of zero when all colours are the same could be the Variance, or its square root, the Standard Devition. if all colours are as different as possible, then the variance would be 2/9 (or 0.2222...). You could use this as a scaling factor as follows. Assuming that R, G and B are in the range 0..1, then:

DR=1-variance(SR,SG,SB)×9/2

With identical values for DG and DB.

I have not tried this yet, but I might do when I get to my desktop.

John


Windows 10, Affinity Photo 1.7 and Designer 1.7, (mainly Photo), now ex-Adobe CC

CPU: AMD A6-3670. RAM: 16 GB DDR3 @ 666MHz, Graphics: 2047MB NVIDIA GeForce GT 630

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×