Last active
June 8, 2021 15:30
-
-
Save tlancon/504f4a666ef49611e14597cbfad83307 to your computer and use it in GitHub Desktop.
Copies the main visualization properties from one layer to another in napari.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def copy_lut(from_layer, to_layer, opacity=False): | |
""" | |
Copies the visualization properties from one layer to another in napari. | |
Only the colormap, contrast limits, and gamma values are included by default. | |
The opacity can be optionally copied as well. | |
Blending and interpolation are ignored. | |
Params | |
------ | |
from_layer : napari Image Layer | |
Image layer with the visualization parameters you'd like to copy from. | |
to_layer : napari Image Layer | |
Image layer that you'd like to copy the visualization parameters to. | |
opacity : Bool | |
If True, copy the opacity value from from_layer to to_layer. | |
Defaults to False. | |
""" | |
to_layer.colormap = from_layer.colormap | |
to_layer.contrast_limits = from_layer.contrast_limits | |
to_layer.gamma = from_layer.gamma | |
if opacity is True: | |
to_layer.opacity = from_layer.opacity |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment