ColorAdjustment¶
lumicks.pylake.ColorAdjustment
- class ColorAdjustment(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:
minimum (array_like) – 1 or 3-component list of lower limits for the color mapping
maximum (array_like) – 1 or 3-component list of upper limits for the color mapping
mode (str) –
“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.
gamma (float) –
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.ImageStack("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)