frank26080115 Posted November 24, 2021 Posted November 24, 2021 I need some way to put a limit on saturation (or some form of non-linear desaturation). I need a filter that basically runs an algorithm that looks like for every pixel, convert RGB value to HSI value. If the S value is greater than X, set it to X, convert that HSI value back into RGB I tried replicating this effect using a S shaped curve for AOpponent and BOpponent with a Curve filter in LAB mode, but I can't get the desired effect. I tried using a normal curve in RGB and then setting the blend mode the Saturation, but the input axis is brightness, so this does not give me the desired effect I tried the threshold filter but I need the input to be saturation I can't seem to find a way of mixing channels in the same way that I can convert between RGB and HSV colour spaces within OpenCV/Numpy Quote
Old Bruce Posted November 24, 2021 Posted November 24, 2021 Isn't there a correlation between the differences between R and G and B and Saturation? If the differences are too large shrink them. Caveat: I really do not know that of which I speak. Quote Mac Pro (Late 2013) Mac OS 12.7.6 Affinity Designer 2.5.7 | Affinity Photo 2.5.7 | Affinity Publisher 2.5.7 | Beta versions as they appear. I have never mastered color management, period, so I cannot help with that.
NotMyFault Posted November 24, 2021 Posted November 24, 2021 (edited) In theory this could be possible with procedural texture filters. I succeeded partially and found formulas for the partial steps, e.g. calculating saturation from RGB, or convert HSL back to RGB. Unfortunately, these formulas get quite lengthy, as the PT filter lacks some essentials like a building rgb-2-HSL conversion. Especially transforming essential if/else into equivalent arithmetic formulas makes everything so complex. I did not try to combine all into one gigantic formula as debugging becomes far too laborious. Alternative ideas: use my PT filter to create a selection of overly saturated pixels Use fill layer with given maximum saturation and blend mode saturation (could be one color set by HSL) I need to split into 3 PT filters, one for every dominant primary color (R,G,B). This will eliminate most of the if/else complexity. The colors can be re-combined later. Could you provide an example document, and the expected result? i will then provide a file with the PT filters. basic start: A=var mi=min(R,G,B); var ma=max(R,G,B);var dd=ma-mi; var ll=(ma+mi)/2; var sat=dd/(1-abs(2*ll-1)); sign(sat-a) with input a=intend saturation maximum level Edited November 24, 2021 by NotMyFault Updated ideas Quote Mac mini M1 A2348 | MBP M3 Windows 11 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 | Dell 27“ 4K iPad Air Gen 5 (2022) A2589 Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps. I use iPad screenshots and videos even in the Desktop section of the forum when I expect no relevant difference.
NotMyFault Posted November 24, 2021 Posted November 24, 2021 (edited) Another idea: add HSL filter and set sat to e.g. +50% add another HSL filter and set sat to -50% This should limit sat to 50%. Pixel with sat <=50% stay unchanged. Pixels with sat >50% get capped at 50%. The test image seem to work at least for the special case (limit sat to 50%) limit saturation.afphoto Edited November 24, 2021 by NotMyFault thomaso 1 Quote Mac mini M1 A2348 | MBP M3 Windows 11 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 | Dell 27“ 4K iPad Air Gen 5 (2022) A2589 Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps. I use iPad screenshots and videos even in the Desktop section of the forum when I expect no relevant difference.
frank26080115 Posted November 25, 2021 Author Posted November 25, 2021 Thanks for the hint! I googled around for tutorials about the procedural texture filter and I found this http://changingminds.org/disciplines/photography/affinity_photo/resources/daves_saturation_selection.htm It doesn't work as well as I'd hope in my situation but I am studying the equation to get a feel for this filter I honestly didn't even know Affinity had macros... Wishing Affinity had RGBtoHSI and HSItoRGB equations, would have made this soooo easy NotMyFault 1 Quote
thomaso Posted November 25, 2021 Posted November 25, 2021 23 hours ago, NotMyFault said: add HSL filter and set sat to e.g. +50% add another HSL filter and set sat to -50% This should limit sat to 50%. Pixel with sat <=50% stay unchanged. Pixels with sat >50% get capped at 50%. Wow, how did you get there? Can you explain why this really works? Why is it important that first +50 gets calculated? I'd expected +/– would cancel each other out, which seems to happen only if the adjustment order gets swapped. Quote macOS 10.14.6 | MacBookPro Retina 15" | Eizo 27" | Affinity V1
NotMyFault Posted November 25, 2021 Posted November 25, 2021 31 minutes ago, thomaso said: Wow, how did you get there? Can you explain why this really works? Why is it important that first +50 gets calculated? I'd expected +/– would cancel each other out, which seems to happen only if the adjustment order gets swapped. The trick is +50% cannot go over 100%, it gets capped at 100%. Column1 v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 old value 0 10 20 30 40 50 60 70 80 90 100 sat +50 0 20 40 60 80 100 100 100 100 100 100 sat -50 0 10 20 30 40 50 50 50 50 50 50 thomaso and Lisbon 2 Quote Mac mini M1 A2348 | MBP M3 Windows 11 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080 LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5 | Dell 27“ 4K iPad Air Gen 5 (2022) A2589 Special interest into procedural texture filter, edit alpha channel, RGB/16 and RGB/32 color formats, stacking, finding root causes for misbehaving files, finding creative solutions for unsolvable tasks, finding bugs in Apps. I use iPad screenshots and videos even in the Desktop section of the forum when I expect no relevant difference.
Recommended Posts
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.