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 i9 Custom + Philips 40in 4K & Benq 23in; Surface Pro 4 i5; iPad Pro 11"

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 i9 Custom + Philips 40in 4K & Benq 23in; Surface Pro 4 i5; iPad Pro 11"

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 i9 Custom + Philips 40in 4K & Benq 23in; Surface Pro 4 i5; iPad Pro 11"

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 i9 Custom + Philips 40in 4K & Benq 23in; Surface Pro 4 i5; iPad Pro 11"

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.8,5 Designer 1.8.5 and Publisher 1.8.5 (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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

Please note the Annual Company Closure section in the Terms of Use. These are the Terms of Use you will be asked to agree to if you join the forum. | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.