MCPcopy Index your code
hub / github.com/plotly/plotly.py / intensity_range

Function intensity_range

plotly/express/imshow_utils.py:44–84  ·  view source on GitHub ↗

Return image intensity range (min, max) based on desired value type. Parameters ---------- image : array Input image. range_values : str or 2-tuple, optional The image intensity range is configured by this parameter. The possible values for this parameter are

(image, range_values="image", clip_negative=False)

Source from the content-addressed store, hash-verified

42
43
44def intensity_range(image, range_values="image", clip_negative=False):
45 """Return image intensity range (min, max) based on desired value type.
46
47 Parameters
48 ----------
49 image : array
50 Input image.
51 range_values : str or 2-tuple, optional
52 The image intensity range is configured by this parameter.
53 The possible values for this parameter are enumerated below.
54
55 'image'
56 Return image min/max as the range.
57 'dtype'
58 Return min/max of the image's dtype as the range.
59 dtype-name
60 Return intensity range based on desired `dtype`. Must be valid key
61 in `DTYPE_RANGE`. Note: `image` is ignored for this range type.
62 2-tuple
63 Return `range_values` as min/max intensities. Note that there's no
64 reason to use this function if you just want to specify the
65 intensity range explicitly. This option is included for functions
66 that use `intensity_range` to support all desired range types.
67
68 clip_negative : bool, optional
69 If True, clip the negative range (i.e. return 0 for min intensity)
70 even if the image dtype allows negative values.
71 """
72 if range_values == "dtype":
73 range_values = image.dtype.type
74
75 if range_values == "image":
76 i_min = np.min(image)
77 i_max = np.max(image)
78 elif range_values in DTYPE_RANGE:
79 i_min, i_max = DTYPE_RANGE[range_values]
80 if clip_negative:
81 i_min = 0
82 else:
83 i_min, i_max = range_values
84 return i_min, i_max
85
86
87def _output_dtype(dtype_or_range):

Callers 1

rescale_intensityFunction · 0.85

Calls 1

minMethod · 0.45

Tested by

no test coverage detected