lumicks.pylake.ColorAdjustment

class ColorAdjustment(minimum, maximum, mode='absolute', gamma=1)

Color adjustment for plotting

__init__(minimum, maximum, mode='absolute', gamma=1)

Utility class to adjust the min/max values of image colormaps.

Values can be supplied as a single number or 1-component list, in which case the value is applied to all color channels, or a 3-component list specifying the values for red, green, and blue channels.

Parameters
minimumarray_like

1 or 3-component list of lower limits for the color mapping

maximumarray_like

1 or 3-component list of upper limits for the color mapping

modestr
  • “percentile” : color limits are given as percentiles of the image in question. Percentiles are calculated for each color channel separately

  • “absolute” : color limits are given as absolute values.

Note: When providing bounds in percentiles, limits will change depending on which image you are looking at. When scrolling through a stack of images, the limits will not remain constant.

gammafloat

1 or 3-component list of gamma adjustments.

Applies a power law to the data according to: ((data - vmin) / (vmax - vmin)) ** gamma

Examples

from lumicks import pylake
file = pylake.File("example.h5")

# Plot scan with red color mapped from 5th to 95th percentile.
adjustment = lk.ColorAdjustment(5, 95, mode="percentile")
file.scans["scan"].plot(channel="red", adjustment=adjustment)

# Plot scan with RGB colors mapped from 5th to 95th percentile.
adjustment = lk.ColorAdjustment([5, 5, 5], [95, 95, 95], mode="percentile")
file.scans["scan"].plot(adjustment=adjustment)

stack = lk.CorrelatedStack("camera_recording.tiff")
# Plot force 1x with this stack and adjust the contrast by specifying an absolute upper
# and lower bound for the intensities.
absolute_adjustment = lk.ColorAdjustment([50, 30, 20], [1000, 195, 95])
stack.plot_correlated(file.force1x, channel="rgb", adjustment=absolute_adjustment)

Methods

_get_data_rgb(image)

Scale RGB data for plotting.

_update_limits(image_handle, image, channel)

Update color limits on an image generated by matplotlib.pyplot.imshow()

nothing()