Skip to content

Conversation

@stnKrisna
Copy link
Contributor

The idea is to use external raster mask to mask out areas parametric & drawn mask that we don't want them to take effect (i.e. background exposure).

Screenshot 2025-11-25 at 11 56 38 pm

Changes to pixel pipeline is not implemented yet

@ralfbrown
Copy link
Collaborator

I've had thoughts about adding raster masks to the conditional blending, but never got around to implementing anything. My idea was to treat the raster mask as just another "shape" in drawn masks (which would also allow multiple rasters to be combined with AND/OR/XOR/ANDNOT). Internally, darktable generates a raster mask for each drawn shape and then merges those layers into the final drawn mask. Adding a raster as another layer would take very little code beyond the GUI stuff to select the raster.

@TurboGit TurboGit added this to the 5.6 milestone Nov 25, 2025
@stnKrisna
Copy link
Contributor Author

@ralfbrown Sounds good! What I've been thinking is to multiply the raster mask with the mask generated by drawn and/or parametric mask.

Can you point me to the function that merges layers into the final drawn mask?

@ralfbrown
Copy link
Collaborator

Not an expert on that part of the codebase, but I'd start in files src/develop/masks.h and src/develop/masks/masks.c. My suggestion after a quick scan of those files: Add a new value to dt_masks_type_t and update dt_masks_create() to setup the config for copying a raster mask as a "shape". This involves writing several (but not all) of the functions that a dt_masks_functions_t struct points at; look in src/develop/masks/circle.c for probably the simplest model for those functions. My first impression is you'll need set_form_name, get_mask, get_mask_roi, and possibly get_area/get_source_area; sanitize_config is probably a good idea but not strictly required.

After that, there's a good chance that the existing machinery will just work, letting you use the mask manager module to specify combination methods (union/intersection/diff/sum).

@TurboGit
Copy link
Member

@stnKrisna : Please do not merge origin/master into your topic branch. If needed do a rebase. TIA.

@stnKrisna
Copy link
Contributor Author

@ralfbrown It took me a while to implement this. But I got a working prototype.
Screenshot 2025-11-26 at 11 33 20 pm

Also, as of now, I don't think any of the mask operations are working. The only way to invert the raster mask is to invert it in another module (or original module) before using it.
Screenshot 2025-11-26 at 11 29 33 pm

As of now, to load the raster mask into the drawn mask, you'd need to configure the raster map and switching back to the drawn & parametric mask. I need suggestion how to best load the raster mask into the raster shape.
Screenshot 2025-11-26 at 11 30 01 pm

Also, it's currently not possible to select the raster "shape" in the viewport, as I think this would block selection of other drawn masks. When updating shape of the raster mask, it will not update the mask value when used in the parametric "shape".

@stnKrisna
Copy link
Contributor Author

Implementing the _raster_get_mask_roi fixed some of the issues. Raster "shape" and drawn mask is now intersecting as expected.
Screenshot 2025-11-27 at 12 10 12 am

@ralfbrown
Copy link
Collaborator

currently not possible to select the raster "shape" in the viewport, as I think this would block selection of other drawn masks.

Yeah, that might be tricky. The obvious idea is to treat raster as being "behind" all drawn shapes, i.e. selected whenever the mouse is not over or near-enough a drawn shape. You can probably achieve that by returning a fixed distance equal to the maximum distance at which a shape gets selected. Won't help when multiple raster masks are enabled, though, and I'm not sure how to indicate that the raster is currently selected (beyond the hinter message) since there's no outline to emphasize.

@RawConvert
Copy link

If you're expanding mask functionality, I offer up this -
https://discuss.pixls.us/t/strategies-for-masking-fragmented-areas/42601/24?u=rawconvert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants