Jump to content
You must now use your email address to sign in [click for more info] ×

How to get correct values for L, not averaged ones


Recommended Posts

Hello,

I've searched the forums here and couldn't find an answer to this question ... so I hope someone can help me ...

I'm doing some experiments relating to image resolution, and I want to turn an RGB image into 4 separate L, R, G and B layers, then recombine them to re-create the original image - basically like an LRGB astrophotography image.

I expected the HSL filter with saturation set to zero to give me a layer with the **true** grey values for each pixel, but it doesn't do that - it actually calculates the average of the RGB values, then assigns that as a grey value.

So for example, if a pixel is RGB = 55, 67, 82, I want the L value for that pixel to be equal to the base gray level for that pixel  :-

L = 55

and the corresponding values in the RGB layers to be the difference between the original RGB value and the base gray level :-

R = 55 - 55 = 00

G = 67 - 55 = 12

B = 82 - 55 = 27

This way, I can then add the RGB values (00, 12, 27) back to the L value (55) to reconstruct the original RGB value (55, 67, 82).

This would give me a luminance layer, and individual R G and B layers which, when added together, are the same as the original image.

But AP doesn't work that way.

If I set the HSL saturation to zero for the same pixel, the value of L that AP gives me for that pixel is the average of the RGB values :-

L = (55 + 67 + 82)/3 = 68

rather than the minimum value (55) - which is what I expected.

Can anyone help me create a layer that is a grayscale image, with the value of each pixel equal to the minimum value (not the average) of the RGB values for each pixel in the original RGB image ?

Many thanks :)

Link to comment
Share on other sites

This procedural texture will take the minimum RGB value and apply to all channels - check a random pixel with the effect off and on

image.png.37fe9f3a62a784c6c327334641d119ca.png

 

This one subtracts the minimum grey values

image.png.e28158c284a3c0b705908d5a3c8cb033.png

 

Now do a merge visible using both procedural textures in turn, put the grey one at the top, change its blend mode to add and the original image is rebuilt. Hope that's of help

image.jpeg.b5462f6691ed079a39093169f5f2de18.jpeg

Microsoft Windows 11 Home, Intel i7-1360P 2.20 GHz, 32 GB RAM, 1TB SSD, Intel Iris Xe
Affinity Photo - 24/05/20, Affinity Publisher - 06/12/20, KTM Superduke - 27/09/10

Link to comment
Share on other sites

Affinity uses the Rec.709 coefficients to calculate luma in HSL

https://en.wikipedia.org/wiki/Rec._709

When encoding Y’CBCR video, BT.709 creates gamma-encoded luma (Y’) using matrix coefficients 0.2126, 0.7152, and 0.0722 (together they add to 1)

Mac mini M1 A2348 | Windows 10 - AMD Ryzen 9 5900x - 32 GB RAM - Nvidia GTX 1080

LG34WK950U-W, calibrated to DCI-P3 with LG Calibration Studio / Spider 5

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.

 

Link to comment
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

Terms of Use | 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.