Strategies for masking fragmented areas

I still believe that an expansion through fresh samples is a far more logical direction than simply expanding for one or two pixels at a time.
There also is a possibility that mask expansion is more reasonable when (for instance) jz, Cz and hz are all working together. That was certainly the answer based on my past experience.


It finally dawned on me … mask (negative) on the trees and mask (negative) on the lower part of the image.
Except for a very few light spots on the tree bark, the trees are totally clear of the mask.
Not sure that this is a solution for other fragmented areas but it does work in this case.

Very clean result!

3 Likes

IMHO darktable mask system is great for most usual cases, when there exists a subset of parameters which can overlap with the semantic of the texture you want to mask. But indeed it has some limitations:

  • Sometimes, parameters are not enough (or they capture unwanted parts of the image, or the miss parts of the image). In this case, manual editing/tweaking/ can be long and painful ;
  • Precise manual contour editing for complex shapes and textures is long and meticulous (peoples, cars) ;
  • I sometimes feel it lacks shape composition features: how to add an area by shape and at the same time remove another one with another shape? (or maybe I missed something in dt)

More generally, I feel that darktable masks allow to technically mask almost anything, but the process to achieve complex cases is long and complicated with a lot of tweaking with feathering/contrast, opacity as well a drawing.

In my opinion, a rare benefit of IA for RAW photo editing could be a masking helper. There is this masking AI model from Meta, Segment Anything, which has great potential. See the (low resolution) demo here. I understood that you could also text prompt it.

I don’t have the skills to implement this in darktable but I’m considering building a small tool to extract raster masks from prompts when I’ll have some time.

My edit:


DSCF3968.RAF.xmp (17.6 KB)

I find DT’s masking functionality usually sufficient but sometimes I could use more power. This thread gave me an idea for flexibly combining raster masks.

It’s the MMM, the Mask Manipulator Module, a new module, and being based on raster masks, it effectively supports parametric masks, which the Mask Manager doesn’t. You can put an instance anywhere in the pipe and it will combine raster masks which are “live” at that point, producing an output raster mask which is then “live” from that point on. You can probably imagine the way it could combine masks -

AND (“Exclusive” in module masking, “Intersection” in Mask Manager) for 2 or more masks
OR (“Inclusive” in module masking, “Union” in Mask manager) for 2 or more masks
EXCLUSIVE OR ("Exclusion in Mask Manager) for 2 or more masks
MINUS (“Difference” in Mask manager) for 2 masks

It would need to perform sensible operations on pixel opacities similar to those already in Mask manager, e.g. where a pixel is in more than one mask the user can choose min max or a mean. For MINUS there’s the option to exclude the pixels being subtracted completely, or subtract opacity.

You could allow a mask to be inverted before combining, as currently happens.

You could have the option to delete input masks after combining, this would presumably reduce memory needs.

Multiple instances would allow a complex mask to be built in stages.