Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/core/utils/imageutils.py: 33%
6 statements
« prev ^ index » next coverage.py v7.6.5, created at 2024-11-15 02:12 +0000
« prev ^ index » next coverage.py v7.6.5, created at 2024-11-15 02:12 +0000
1"""
2Helper to deal with image data
3"""
5from silx.math import colormap
8def array_to_image(array, autoscale="none", norm="linear", lut="gray"):
9 """Convert an array into a displayable array (uint8, RGBA)
11 Arguments:
12 array: An intensity numpy array
13 norm: One of 'linear', 'log', 'arcsinh', 'sqrt'
14 lut: One of 'gray', 'gray_r', 'viridis', 'cividis'...
15 autoscale: One of 'none', 'minmax', 'stddev3'
16 """
17 if autoscale == "none":
18 vmin, vmax = 0, 255
19 else:
20 vmin, vmax = None, None
21 return colormap.apply_colormap(
22 array, colormap=lut, norm=norm, autoscale=autoscale, vmin=vmin, vmax=vmax
23 )