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

Edit Mask as Pixel Layer


Recommended Posts

You might want to use a pixel layer as mask layer, but still be able to edit this layer and see the impact of your edits live.

This is easily possible:

  1. Start with at least a background layer and a second pixel layer intended for masking
  2. add the live procedural text filter with this formula A=R, R=1, G=1, B=1 (or download preset "grey to alpha" below)
  3. Clip this live filter to the pixel layer to be used for masking
  4. Clip "pixel mask layer to be used for marking" to the background layer where you want to use it. The procedural text filter will become invisible in the layer stack, but still working.
  5. Modify the "pixel mask" layer with any pixel tool you like: brush, dodge and burn, sharpen, any adjustment or any filter
  6. At least give a "heart" or "thanks" to my post.

Bonus material:

  • If you have a mask you want to transform into a pixel layer, you can simply use the procedural text filter "alpha to gray" (see attached file).

Video Tutorial:

The recording did not capture the live procedural text filter. please use the settings from the picture below:

 

Have fun

 

 

 

alpha to gray.aftoolpresets grey to alpha.aftoolpresets

lptf.JPG

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.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

Thanks.

However, this would make a lot more sense if you included the additional information from the other thread where you mentioned it: https://forum.affinity.serif.com/index.php?/topic/131750-make-pixels-semi-transparent-based-on-brightness-and-saturation/&do=findComment&comment=726326

 

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
    Laptop 2: Windows 11 Pro 24H2,  16GB memory, Snapdragon(R) X Elite - X1E80100 - Qualcomm(R) Oryon(TM) 12 Core CPU 4.01 GHz, Qualcomm(R) Adreno(TM) X1-85 GPU
iPad:  iPad Pro M1, 12.9": iPadOS 17.7, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.7

Link to comment
Share on other sites

Hi Walt,

 

will do after finishing my business work. It takes a lot of time to create and polish a tutorial. The other thread only touched an edge case, this method has a broader scope.

 

 

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.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

Understood. But, perhaps, better to wait to post it until it is complete, to avoid confusion.

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
    Laptop 2: Windows 11 Pro 24H2,  16GB memory, Snapdragon(R) X Elite - X1E80100 - Qualcomm(R) Oryon(TM) 12 Core CPU 4.01 GHz, Qualcomm(R) Adreno(TM) X1-85 GPU
iPad:  iPad Pro M1, 12.9": iPadOS 17.7, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.7

Link to comment
Share on other sites

Now you will find a updated tutorial, a video tutorial, and updated presets which will simlify the workflow.

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.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

  • 1 month later...
On 1/25/2021 at 2:35 PM, NotMyFault said:

You might want to use a pixel layer as mask layer, but still be able to edit this layer and see the impact of your edits live.

After playing with your method for a while tonight:
Perhaps I'm missing something, but what exactly can it do that cannot be done with a simple mask layer?

MacBookAir 15": MacOS Ventura > Affinity v1, v2, v2 beta // MacBookPro 15" mid-2012: MacOS El Capitan > Affinity v1 / MacOS Catalina > Affinity v1, v2, v2 beta // iPad 8th: iPadOS 16 > Affinity v2

Link to comment
Share on other sites

Hi Lukas,

A mask layer is a kind of second class citizen, especially before 1.9.

To edit a mask layer, only a few adjustment or live filters are available (e.g. levels and curves have option to affect alpha layer). 
Some users expressed wanting to use all regular tools, e.g. dodge and burn, and any adjustment or filter, to edit masks, without need for (destructive) conversion. 
 

Have you ever tried to use geometric functions like add to merge 2 masks? For pixel layers, it‘s easy and direct (blend mode add). For masks, you need to think outside the box, e.g. create selection from first mask, then paint in white on second mask.

Ever tried to paste something into a mask?

Tried to use blend levels on alpha channel?

Tried to use picker for curves adjustment layer on alpha channel? It picks RGB instead of alpha channel, making it useless.

I hope this might show some issues where the tutorial might provide an alternative approach. 

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.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

Hi,

That's a good idea!

1. How does this differ from your (R+G+B)/3=A formula?
2. Is it possible to invert an image using a formula?

Link to comment
Share on other sites

16 hours ago, NotMyFault said:

Have you ever tried to […]

Frankly, not much. I'm mainly a typography and vector guy, having used pixel editors mostly for very basic things like slightly color-adjusting photos that I'd place in a layout and the like. I don't even have much idea what Photoshop CS5 can do with all those masks and channels, even though I've been using Photoshop since the mid-1990s.

But that's OK. I was asking because with my puny knowledge of masking, so far I was doing fine with it as is.

MacBookAir 15": MacOS Ventura > Affinity v1, v2, v2 beta // MacBookPro 15" mid-2012: MacOS El Capitan > Affinity v1 / MacOS Catalina > Affinity v1, v2, v2 beta // iPad 8th: iPadOS 16 > Affinity v2

Link to comment
Share on other sites

17 hours ago, telemax said:

1. How does this differ from your (R+G+B)/3=A formula?
2. Is it possible to invert an image using a formula?

Hi telemax,

ad 1:
When using a pixel layer as mask, you need only the luminosity value (or grey level). If your pixel layer is gray, you can use any color channel, all values are equal. For the more general case where you have a colored pixel layer, R, G, B will be uneuqal, and i use the average (R+G+B)/3.

ad 2:
to invert x, simply use 1-x in the formulas.

Actually, most of the adjustment layers can be simulated by simple formulas.

invert: 1-R / 1-G / 1-B

 

 

 

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.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

Thanks!

One more question, how to desaturate with a Procedural texture?
This formula works! Is this correct? Is this the right way, or not?

RGB_to_Grey.png.19ed9eba9d176e76d134eae5bb6646c1.png

 

Link to comment
Share on other sites

Hi

(R+G+B)/3 ?

Sorry that doesn't make sense. We have a significant different weighting for each channel; predominance of Green channel

Also you can't just sum the three channels together and divide by three and get something close to the actual luminance of a particular color.

 

Link to comment
Share on other sites

22 minutes ago, Max P said:

Hi

(R+G+B)/3 ?

Sorry that doesn't make sense. We have a significant different weighting for each channel; predominance of Green channel

Also you can't just sum the three channels together and divide by three and get something close to the actual luminance of a particular color.

 

Hi Max,

In the sense of constructive critique, i would have prefered to receive a better formula from you.

For those who prefere the full gold card VIP package of ready-to-use filters on a silver tablet, you can find more hints below.

The example above is intentionally only the most basic method, as we use this in the context of the intended purpose for masking, and not for HDTV greyscale conversion.

To start with:

image.png.45d7ad07ac485b1182af069535cdc6c3.png

This goes more into the direction of the B&W adjustment filter

image.png.b6dcb5cfdabd5372dac50a0d7b300967.png

 

To go further, lookup the factors in wikipedia to achive results compatible to ITU standard.

https://en.wikipedia.org/wiki/Grayscale

Luma coding in video systems

Main article: luma (video)

For images in color spaces such as Y'UV and its relatives, which are used in standard color TV and video systems such as PAL, SECAM, and NTSC, a nonlinear luma component (Y') is calculated directly from gamma-compressed primary intensities as a weighted sum, which, although not a perfect representation of the colorimetric luminance, can be calculated more quickly without the gamma expansion and compression used in photometric/colorimetric calculations. In the Y'UV and Y'IQ models used by PAL and NTSC, the rec601 luma (Y') component is computed as

Y′=0.299R′+0.587G′+0.114B′{\displaystyle Y'=0.299R'+0.587G'+0.114B'}Y'=0.299R'+0.587G'+0.114B'

where we use the prime to distinguish these nonlinear values from the sRGB nonlinear values (discussed above) which use a somewhat different gamma compression formula, and from the linear RGB components. The ITU-R BT.709 standard used for HDTV developed by the ATSC uses different color coefficients, computing the luma component as

Y′=0.2126R′+0.7152G′+0.0722B′{\displaystyle Y'=0.2126R'+0.7152G'+0.0722B'}Y'=0.2126R'+0.7152G'+0.0722B'.

Although these are numerically the same coefficients used in sRGB above, the effect is different because here they are being applied directly to gamma-compressed values rather than to the linearized values. The ITU-R BT.2100 standard for HDR television uses yet different coefficients, computing the luma component as

Y′=0.2627R′+0.6780G′+0.0593B′{\displaystyle Y'=0.2627R'+0.6780G'+0.0593B'}{\displaystyle Y'=0.2627R'+0.6780G'+0.0593B'}.

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.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

For greyscale conversion with procedural texture, it seems there is a dedicated function

rgbtoi(R,G,B)

But i could not find any description about what conversion method (factors for color channel) is used.

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.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites


according with you, NotMyFault


First I dont' want use RGBtoi ,  because  integer  8 bit , (255) perhaps  16 bit, loss of accuracy, salt noise..

 prefer work 32 Bit for calculate


I use this one Y′=0.299R′+0.587G′+0.114B′  or  Y'=0.2126R'+0.7152G'+0.0722B'

It 's give me Y'  Mode Luminosity
  I made a copy, substract to a copy of backroung
  merge it, obtain a color  layer mode color ( as  l*a*b*)
  Perhaps it' s not so correct, but Okay for my use
 
If you are no afraid with code, just see arithmetic ,
https://stackoverflow.com/questions/56198778/what-is-the-efficient-way-to-calculate-human-eye-contrast-difference-for-rgb-val/56200738#56200738

 

Link to comment
Share on other sites

Hi Max,

 

i just checked, rgbtoi uses ITU-R 601 for conversion

 

Y′=0.299R′+0.587G′+0.114B′{\displaystyle Y'=0.299R'+0.587G'+0.114B'}Y'=0.299R'+0.587G'+0.114B'
 
by measuring (info panel) the result for a full red/green/blue pixel.
These values match within the limits

image.png.a9b04f8f41d6a616f3d4567c8d035221.png

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.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

1 hour ago, Max P said:

[...]
First I dont' want use RGBtoi ,  because  integer  8 bit , (255) perhaps  16 bit, loss of accuracy, salt noise..

 prefer work 32 Bit for calculate

[...]

  merge it

[...]

 

Hi Max,

RGBTOI works flawless in full 8, 16 and 32 bit depth.

The effects you are describing is the result of something different: using "merge visible" from layers containing fill gradients.

It is an old but still unsolved bug (or dev's see this as "by design") that Photo uses forced 8 bit dithering for "merge visisble" AND gradient fills.

I personally use PT instead of gradient fill when possible to avoid this.

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.

My posts focus on technical aspects and leave out most of social grease like „maybe“, „in my opinion“, „I might be wrong“ etc. just add copy/paste all these softeners from this signature to make reading more comfortable for you. Otherwise I’m a fine person which respects you and everyone and wants to be respected.

 

Link to comment
Share on other sites

Ping! Penny drops on what rgbtoi does -- luma values. Thanks. For convenience I sometimes refer to this as 361 - RGB approx 30%, 60%, 10%. Ballpark of course, thougn on-screen i found little discernable difference when picking 1% apart. It was an aha for me to discover the difference between HSL desaturation and Vibrance desaturation.

Don't know if this is relevant to the discussion, but a very quick way to do a very flexible pixel layer mask is to:

  • Duplicate layer or merge visible as desired.
  • Add new pixel layer above.
  • Group duplicated layer and pixel layer.
  • Change blend mode of pixel layer to Erase.
  • Add pixels by any method to the pixel layer (including partially transparent ones).

Erase blend knocks out all pixels below but stops at the end of a group. It looks like it uses the inverse of pixel alpha, so adding pixels removes ones below.

I think that in this, only the alpha value of the pixel mask layer influences the mask effect, not luminosity calculation.

 

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.

Link to comment
Share on other sites

  • 6 months later...

I created this account just to say thank you to NotMyFault. The lack of (knowing how to) pack textures including the alpha channel without messing with the information stored in RGB has been the only thing I disliked about using affinity photo for ... years probably. This is the most helpful post for me I have come across so far. 💖

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.