Heal out-of-gamut regions in a Lab image using diffusion-based inpainting.
Parameters
----------
lab_image : `LABImage`
A NxMx3 array in the Lab colorspace. Modified in-place by healing out-of-gamut regions.
For each region, a copy is made before modification, then written back.
mask : `numpy.ndarray` of `bool`
A boolean mask indicating which pixels are out of gamut.
xyz_whitepoint : `tuple` of `float`, `float`
Sets the white point of the xyz colorspace in xy coordinates.
max_size : `int`, optional
Maximum size of regions to heal. Larger regions are skipped. Default is 500.
dilation_iterations : `int`, optional
Number of iterations for mask dilation. Default is 3.
Returns
-------
result : `RGBImage`
The healed image converted to RGB colorspace.
Raises
------
ValueError
Raised if the shapes of lab_image and mask are incompatible.
Notes
-----
The healing algorithm works by:
1. Labeling connected regions in the mask
2. For each region smaller than max_size:
- Dilating the mask to create an annulus around the region
- Computing average a,b color values from the annulus
- Using rgb.inpaint_mask to interpolate the L, a, and b channels
- Filling the masked region with the interpolated values
3. Regions larger than max_size are skipped.
Definition at line 39 of file _gamut_fixer.py.