lsst.pipe.tasks g0e6ec694fa+22317780d5
Loading...
Searching...
No Matches
lsst.pipe.tasks.prettyPictureMaker._colorMapper Namespace Reference

Functions

NDArray latLum (values, float stretch=400, float max=1, float floor=0.00, float Q=0.7, bool doDenoise=False, float highlight=1.0, float shadow=0.0, float midtone=0.5)
 
NDArray mapUpperBounds (NDArray img, float quant=0.9, float|None absMax=None)
 
tuple[NDArray, NDArray] colorConstantSat (NDArray oldLum, NDArray luminance, NDArray a, NDArray b, float saturation=0.6, float maxChroma=80)
 
NDArray fixOutOfGamutColors (NDArray Lab, str colourspace="Display P3", Literal["mapping", "inpaint"] gamutMethod="inpaint")
 
 _fuseExposure (images, sigma=0.2, maxLevel=3)
 
 _handelLuminance (NDArray img, Callable[..., NDArray]|None scaleLum=latLum, Mapping|None scaleLumKWargs=None, Callable|None remapBounds=mapUpperBounds, Mapping|None remapBoundsKwargs=None, bool doLocalContrast=True, float sigma=30, float highlights=-0.9, float shadows=0.5, float clarity=0.1, int|None maxLevel=None, tuple[float, float] cieWhitePoint=(0.28, 0.28), float bracket=1, NDArray|None psf=None)
 
NDArray lsstRGB (NDArray rArray, NDArray gArray, NDArray bArray, bool doLocalContrast=True, Callable[..., NDArray]|None scaleLum=latLum, Mapping|None scaleLumKWargs=None, Callable[..., tuple[NDArray, NDArray]]|None scaleColor=colorConstantSat, Mapping|None scaleColorKWargs=None, Callable|None remapBounds=mapUpperBounds, Mapping|None remapBoundsKwargs=None, tuple[float, float] cieWhitePoint=(0.28, 0.28), float sigma=30, float highlights=-0.9, float shadows=0.5, float clarity=0.1, int|None maxLevel=None, NDArray|None psf=None, list[float]|None brackets=None, bool doRemapGamut=True, Literal["mapping", "inpaint"] gamutMethod="inpaint")
 

Function Documentation

◆ _fuseExposure()

lsst.pipe.tasks.prettyPictureMaker._colorMapper._fuseExposure ( images,
sigma = 0.2,
maxLevel = 3 )
protected

Definition at line 286 of file _colorMapper.py.

◆ _handelLuminance()

lsst.pipe.tasks.prettyPictureMaker._colorMapper._handelLuminance ( NDArray img,
Callable[..., NDArray] | None scaleLum = latLum,
Mapping | None scaleLumKWargs = None,
Callable | None remapBounds = mapUpperBounds,
Mapping | None remapBoundsKwargs = None,
bool doLocalContrast = True,
float sigma = 30,
float highlights = -0.9,
float shadows = 0.5,
float clarity = 0.1,
int | None maxLevel = None,
tuple[float, float] cieWhitePoint = (0.28, 0.28),
float bracket = 1,
NDArray | None psf = None )
protected

Definition at line 339 of file _colorMapper.py.

◆ colorConstantSat()

tuple[NDArray, NDArray] lsst.pipe.tasks.prettyPictureMaker._colorMapper.colorConstantSat ( NDArray oldLum,
NDArray luminance,
NDArray a,
NDArray b,
float saturation = 0.6,
float maxChroma = 80 )
Adjusts the color saturation while keeping the hue constant.

This function adjusts the chromaticity (a, b) of colors to maintain a
consistent saturation level, based on their original luminance. It uses
the CIELAB color space representation and the `luminance` is the new target
luminance for all colors.

Parameters
----------
oldLum : `NDArray`
    Luminance values of the original colors.
luminance : `NDArray`
    Target luminance values for the transformed colors.
a : `NDArray`
    Chromaticity parameter 'a' corresponding to green-red axis in CIELAB.
b : `NDArray`
    Chromaticity parameter 'b' corresponding to blue-yellow axis in CIELAB.
saturation : `float`, optional
    Desired saturation level for the output colors. Defaults to 1.
maxChroma : `float`, optional
    Maximum chroma value allowed for any color. Defaults to 50.

Returns
-------
new_a : NDArray
    New a values representing the adjusted chromaticity.
new_b : NDArray
    New b values representing the adjusted chromaticity.

Definition at line 160 of file _colorMapper.py.

◆ fixOutOfGamutColors()

NDArray lsst.pipe.tasks.prettyPictureMaker._colorMapper.fixOutOfGamutColors ( NDArray Lab,
str colourspace = "Display P3",
Literal["mapping", "inpaint"] gamutMethod = "inpaint" )
Remap colors that fall outside an RGB color gamut back into it.

This function modifies the input Lab array in-place for memory reasons.

Parameters
----------
Lab : `NDArray`
    A NxMX3 array that contains data in the Lab colorspace.
colourspace : `str`, optional
    The target colourspace to map outlying pixels into. This must
    correspond to an RGB colourspace understood by the colour-science
    python package.
gamut_method : `str`, optional
    This determines what algorithm will be used to map out of gamut
    colors. Must be one of ``mapping`` or ``inpaint``.

Definition at line 236 of file _colorMapper.py.

◆ latLum()

NDArray lsst.pipe.tasks.prettyPictureMaker._colorMapper.latLum ( values,
float stretch = 400,
float max = 1,
float floor = 0.00,
float Q = 0.7,
bool doDenoise = False,
float highlight = 1.0,
float shadow = 0.0,
float midtone = 0.5 )
Scale the input luminosity values to maximize the dynamic range visible.

Parameters
----------
values : `NDArray`
    The input image luminosity data of of.
stretch : `float`, optional
    A parameter for the arcsinh function.
max : `float`, optional
    Maximum value for intensity scaling on a scale of 0-1.
floor : `float`, optional
    A value added to each pixel in arcsinh transform, this ensures values in
    the arcsinh transform is no smaller than the supplied value.
Q : `float`, optional
    Another parameter for the arcsinh function and scaling factor for
    softening.
doDenoise : `bool`, optional
    Denoise the image if desired.
highlight : `float`
    This is the value (between 0 and 1) that maps to be "white" in the
    output. Decreasing this makes fainter things more luminous but
    clips the brightest end. This is a linear transform applied to the
    values after arcsinh.
shadow : `float`
    This is the value (between 0 and 1) that maps to be "black" in the
    output. Increasing this makes fainter things darker but
    clips the lowest values. This is a linear transform applied to the
    values after arcsinh.
midtone : `float`
    This is the value (between 0 and 1) that adjusts the balance between
    white and black. Decreasing this makes fainter things more luminous,
    increasing does the opposite. This is a linear transform applied to the
    values after arcsinh.

Returns:
    luminance : `NDArray`
        The stretched luminosity data.

Definition at line 17 of file _colorMapper.py.

◆ lsstRGB()

NDArray lsst.pipe.tasks.prettyPictureMaker._colorMapper.lsstRGB ( NDArray rArray,
NDArray gArray,
NDArray bArray,
bool doLocalContrast = True,
Callable[..., NDArray] | None scaleLum = latLum,
Mapping | None scaleLumKWargs = None,
Callable[..., tuple[NDArray, NDArray]] | None scaleColor = colorConstantSat,
Mapping | None scaleColorKWargs = None,
Callable | None remapBounds = mapUpperBounds,
Mapping | None remapBoundsKwargs = None,
tuple[float, float] cieWhitePoint = (0.28, 0.28),
float sigma = 30,
float highlights = -0.9,
float shadows = 0.5,
float clarity = 0.1,
int | None maxLevel = None,
NDArray | None psf = None,
list[float] | None brackets = None,
bool doRemapGamut = True,
Literal["mapping", "inpaint"] gamutMethod = "inpaint" )
Enhance the lightness and color preserving hue using perceptual methods.

Parameters
----------
rArray : `NDArray`
    The array used as the red channel
gArray : `NDArray`
    The array used as the green channel
bArray : `NDArray`
    The array used as the blue channel
doLocalContrast: `bool`
    Apply local contrast enhancement algorithms to the luminance channel.
scaleLum : `Callable` or `None`
    This is a callable that's passed the luminance values as well as
    any defined scaleLumKWargs, and should return a scaled luminance array
    the same shape as the input. Set to None for no scaling.
scaleLumKWargs : `Mapping` or `None`
    Key word arguments that passed to the scaleLum function.
scaleColor : `Callable` or `None`
    This is a callable that's passed the original luminance, the remapped
    luminance values, the a values for each pixel, and the b values for
    each pixel. The function is also passed any parameters defined in
    scaleColorKWargs. This function is responsible for scaling chroma
    values. This should return two arrays corresponding to the scaled a and
    b values. Set to None for no modification.
scaleColorKWargs : `Mapping` or `None`
    Key word arguments passed to the scaleColor function.
remapBounds : `Callable` or `None`
    This is a callable that should remaps the input arrays such that each of
    them fall within a zero to one range. This callable is given the
    initial image as well as any parameters defined in the remapBoundsKwargs
    parameter. Set to None for no remapping.
remapBoundsKwargs : `Mapping` or None
cieWhitePoint : `tuple` of `float`, `float`
    This is the white point of the input of the input arrays in CIE XY
    coordinates. Altering this affects the relative balance of colors
    in the input image, and therefore also the output image.
sigma : `float`
    The scale over which local contrast considers edges real and not noise.
highlights : `float`
    A parameter that controls how local contrast enhances or reduces
    highlights. Contrary to intuition, negative values increase highlights.
shadows : `float`
    A parameter that controls how local contrast will deepen or reduce
    shadows.
clarity : `float`
    A parameter that relates to the local contrast between highlights and
    shadow.
maxLevel : `int` or `None`
    The maximum number of image pyramid levels to enhance the local contrast
    over. Each level has a spatial scale of roughly 2^(level) pixels.
psf : `NDArray` or `None`
    If this parameter is an image of a PSF kernel the luminance channel is
    deconvolved with it. Set to None to skip deconvolution.
brackets : `list` of `float` or `None`
    If a list brackets is supplied, an image will  be generated at each of
    the brackets and the results will be used in exposure fusioning to
    increase the apparent dynamic range of the image. The image post bounds
    remapping will be divided by each of the values specified in this list,
    which can be used to create for instance an under, over, and ballanced
    expoisure. Theese will then be fusioned into a final single exposure
    selecting the proper elements from each of the images.
doRemapGamut : `bool`, optional
    If this is `True` then any pixels which lay outside the representable
    color gamut after manipulation will be remapped to a "best" value
    which will be some compromise in hue, chroma, and lum. If this is
    `False` then the values will clip. This may be useful for
    seeing where problems in processing occur.

Returns
-------
result : `NDArray`
    The brightness and color calibrated image.

Raises
------
ValueError
    Raised if the shapes of the input array don't match

Definition at line 393 of file _colorMapper.py.

◆ mapUpperBounds()

NDArray lsst.pipe.tasks.prettyPictureMaker._colorMapper.mapUpperBounds ( NDArray img,
float quant = 0.9,
float | None absMax = None )
Bound images to a range between zero and one.

Some images supplied aren't properly bounded with a maximum value of 1.
Either the images exceed the bounds of 1, or that no value seems to close,
implying indeterminate maximum value. This function determines an
appropriate maximum either by taking the value supplied in the absMax
argument or by scaling the maximum across all channels with the
supplied quant variable.

Parameters
----------
img : `NDArray` like
    Must have dimensions of y,x,3 where the channels are in RGB order
quant : `float`
    Value to scale the maximum pixel value, in any channel, by to
    determine the maximum flux allowable in all channels. Ignored
    if absMax isn't None.
absMax : `float` or `None`
    If this value is not None, use it as the maximum pixel value
    for all channels, unless scaleBoundFactor is set in which case
    it is only the maximum if the value determined from the image
    and quant is larger than scaleBoundFactor times absMax. This is
    to prevent individual frames in a mosaic from being scaled too
    faint if absMax is too large for one region.

Returns
-------
image : `NDArray`
    The result of the remapping process

Definition at line 101 of file _colorMapper.py.