mergechannels 0.3.0__cp313-cp313-musllinux_1_2_armv7l.whl → 0.4.0__cp313-cp313-musllinux_1_2_armv7l.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mergechannels might be problematic. Click here for more details.
- mergechannels/__init__.py +2 -1
- mergechannels/__init__.pyi +13 -4
- mergechannels/_internal.py +40 -46
- mergechannels/mergechannels.cpython-313-arm-linux-musleabihf.so +0 -0
- {mergechannels-0.3.0.dist-info → mergechannels-0.4.0.dist-info}/METADATA +6 -5
- mergechannels-0.4.0.dist-info/RECORD +12 -0
- mergechannels-0.3.0.dist-info/RECORD +0 -12
- {mergechannels-0.3.0.dist-info → mergechannels-0.4.0.dist-info}/WHEEL +0 -0
- {mergechannels-0.3.0.dist-info → mergechannels-0.4.0.dist-info}/licenses/LICENSE +0 -0
mergechannels/__init__.py
CHANGED
|
@@ -3,11 +3,12 @@ from .mergechannels import ( # type: ignore
|
|
|
3
3
|
dispatch_single_channel,
|
|
4
4
|
dispatch_multi_channel,
|
|
5
5
|
)
|
|
6
|
-
from ._internal import merge
|
|
6
|
+
from ._internal import merge, apply_color_map
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
__all__ = [
|
|
10
10
|
'dispatch_single_channel',
|
|
11
11
|
'dispatch_multi_channel',
|
|
12
12
|
'merge',
|
|
13
|
+
'apply_color_map',
|
|
13
14
|
]
|
mergechannels/__init__.pyi
CHANGED
|
@@ -6,11 +6,20 @@ from python.mergechannels._blending import BLENDING_OPTIONS
|
|
|
6
6
|
from python.mergechannels._luts import COLORMAPS
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
def apply_color_map(
|
|
10
|
+
arr: np.ndarray,
|
|
11
|
+
color: COLORMAPS,
|
|
12
|
+
percentiles: tuple[float, float] | None = None,
|
|
13
|
+
saturation_limits: tuple[float, float] | None = None,
|
|
14
|
+
) -> np.ndarray:
|
|
15
|
+
...
|
|
16
|
+
|
|
9
17
|
def merge(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
arrs: Sequence[np.ndarray],
|
|
19
|
+
colors: Sequence[COLORMAPS],
|
|
20
|
+
blending: BLENDING_OPTIONS = 'max',
|
|
21
|
+
percentiles: tuple[float, float] | Sequence[tuple[float, float]] | None = None,
|
|
22
|
+
saturation_limits: tuple[float, float] | Sequence[tuple[float, float]] | None = None,
|
|
14
23
|
) -> np.ndarray:
|
|
15
24
|
...
|
|
16
25
|
|
mergechannels/_internal.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import (
|
|
2
|
+
Sequence,
|
|
3
|
+
Union,
|
|
4
|
+
)
|
|
2
5
|
|
|
3
6
|
import numpy as np
|
|
4
7
|
|
|
@@ -9,57 +12,48 @@ from mergechannels import (
|
|
|
9
12
|
from ._luts import COLORMAPS
|
|
10
13
|
from ._blending import BLENDING_OPTIONS
|
|
11
14
|
|
|
15
|
+
def apply_color_map(
|
|
16
|
+
arr: np.ndarray,
|
|
17
|
+
color: COLORMAPS,
|
|
18
|
+
percentiles: Union[tuple[float, float], None] = None,
|
|
19
|
+
saturation_limits: Union[tuple[float, float], None] = None,
|
|
20
|
+
) -> np.ndarray:
|
|
21
|
+
'''
|
|
22
|
+
apply a color map to an array
|
|
23
|
+
'''
|
|
24
|
+
if saturation_limits is None:
|
|
25
|
+
if percentiles is None:
|
|
26
|
+
percentiles = (1.1, 99.9)
|
|
27
|
+
low, high = np.percentile(arr, percentiles)
|
|
28
|
+
saturation_limits = (low, high)
|
|
29
|
+
|
|
30
|
+
return dispatch_single_channel(
|
|
31
|
+
array_reference=arr,
|
|
32
|
+
cmap_name=color,
|
|
33
|
+
limits=saturation_limits,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
12
37
|
def merge(
|
|
13
38
|
arrs: Sequence[np.ndarray],
|
|
14
39
|
colors: Sequence[COLORMAPS],
|
|
15
40
|
blending: BLENDING_OPTIONS = 'max',
|
|
16
|
-
|
|
41
|
+
percentiles: Union[Sequence[tuple[float, float]], None] = None,
|
|
42
|
+
saturation_limits: Union[Sequence[tuple[float, float]], None] = None,
|
|
17
43
|
) -> np.ndarray:
|
|
18
44
|
'''
|
|
19
45
|
apply cmaps to arrays and blend the colors
|
|
20
46
|
'''
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
f'Got {n_arrs} arrays and {n_colors} colors'
|
|
28
|
-
)
|
|
29
|
-
arr_shapes = [arr.shape for arr in arrs]
|
|
30
|
-
if not len(set(arr_shapes)) == 1:
|
|
31
|
-
raise ValueError(
|
|
32
|
-
f'Expected every array to have the same shape, got {arr_shapes}'
|
|
33
|
-
)
|
|
34
|
-
if len(arr_shapes[0]) not in (2, 3):
|
|
35
|
-
raise ValueError(
|
|
36
|
-
f'Expected every array to be 2D or 3D, got {arr_shapes[0]}'
|
|
37
|
-
)
|
|
38
|
-
arr_dtypes = [arr.dtype for arr in arrs]
|
|
39
|
-
if not len(set(arr_dtypes)) == 1:
|
|
40
|
-
raise ValueError(
|
|
41
|
-
f'Expected every array to have the same dtype, got {arr_dtypes}'
|
|
42
|
-
)
|
|
43
|
-
# endregion
|
|
44
|
-
if n_arrs == 1:
|
|
45
|
-
if arrs[0].dtype == 'uint8':
|
|
46
|
-
limits = (0, 255)
|
|
47
|
-
else:
|
|
48
|
-
low, high = np.percentile(arrs[0], np.array(saturation_limits) * 100)
|
|
49
|
-
limits = (low, high)
|
|
50
|
-
return dispatch_single_channel(
|
|
51
|
-
array_reference=arrs[0],
|
|
52
|
-
cmap_name=colors[0],
|
|
53
|
-
limits=limits,
|
|
54
|
-
)
|
|
55
|
-
else:
|
|
56
|
-
if all(arr.dtype == 'uint8' for arr in arrs):
|
|
57
|
-
limits = (0, 255)
|
|
58
|
-
else:
|
|
59
|
-
limits = tuple(np.percentile(arr, np.array(saturation_limits) * 100) for arr in arrs)
|
|
60
|
-
return dispatch_multi_channel(
|
|
61
|
-
array_references=arrs,
|
|
62
|
-
cmap_names=colors,
|
|
63
|
-
blending=blending,
|
|
64
|
-
limits=limits, # type: ignore
|
|
47
|
+
if saturation_limits is None:
|
|
48
|
+
if percentiles is None:
|
|
49
|
+
percentiles = [(1.1, 99.9)] * len(arrs)
|
|
50
|
+
saturation_limits = tuple(
|
|
51
|
+
np.percentile(arr, ch_percentiles)
|
|
52
|
+
for arr, ch_percentiles in zip(arrs, percentiles) # type: ignore
|
|
65
53
|
)
|
|
54
|
+
return dispatch_multi_channel(
|
|
55
|
+
array_references=arrs,
|
|
56
|
+
cmap_names=colors,
|
|
57
|
+
blending=blending,
|
|
58
|
+
limits=saturation_limits, # type: ignore
|
|
59
|
+
)
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mergechannels
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -50,6 +50,7 @@ pip install git+https://github.com/zacswider/mergechannels.git
|
|
|
50
50
|
|
|
51
51
|
```python
|
|
52
52
|
from skimage import data
|
|
53
|
+
import matplotlib.pyplot as plt
|
|
53
54
|
import mergechannels as mc
|
|
54
55
|
|
|
55
56
|
img = data.camera()
|
|
@@ -116,10 +117,10 @@ b.imshow(
|
|
|
116
117
|
channels,
|
|
117
118
|
colormaps,
|
|
118
119
|
blending='min',
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
),
|
|
120
|
+
percentiles=[(
|
|
121
|
+
1, # bottom 1% of pixels set to black point
|
|
122
|
+
97, # top 3% of pixels set to white point
|
|
123
|
+
)]*len(channels),
|
|
123
124
|
),
|
|
124
125
|
)
|
|
125
126
|
fig.tight_layout()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
mergechannels-0.4.0.dist-info/METADATA,sha256=UFSUXd5ow06vtucS9sA9wum226fAXxzK8oQignieJtY,5762
|
|
2
|
+
mergechannels-0.4.0.dist-info/WHEEL,sha256=8qbut5OV21MVsJh-6koZCKZnnuRHvhBkNK3ct3shD1c,107
|
|
3
|
+
mergechannels-0.4.0.dist-info/licenses/LICENSE,sha256=csvD60rgtSorbYEM3f8867qNyPCzmIXyFNj8h01Bd6c,1071
|
|
4
|
+
mergechannels.libs/libgcc_s-5b5488a6.so.1,sha256=HGKUsVmTeNAxEdSy7Ua5Vh_I9FN3RCbPWzvZ7H_TrwE,2749061
|
|
5
|
+
mergechannels/__init__.py,sha256=87haN6eeG02qnJJerNCb4Tfn-3GpChD89DKsFAYIH3Y,269
|
|
6
|
+
mergechannels/__init__.pyi,sha256=FZYQH4ue5M9r3zeUMHVZoU2D_RYwd3UiVD-GkcReY7M,1011
|
|
7
|
+
mergechannels/_blending.py,sha256=mE5Cr9wvVJRcwfymg_UUZUjdIKx2mldfLU8QJT95bVM,84
|
|
8
|
+
mergechannels/_internal.py,sha256=tMQtEG3s-N8eamqLUPUHy_fTO-7FqR8Q0Xng-4RSAC0,1421
|
|
9
|
+
mergechannels/_luts.py,sha256=RswhkrCGAFtDthmVHt-Kk7lxROwS-kdsQy1EboyUUc8,3009
|
|
10
|
+
mergechannels/mergechannels.cpython-313-arm-linux-musleabihf.so,sha256=2OCUpdal_0DX1GFm_i4k0aY7OPWanXCkJwfAKtPrMcc,1157721
|
|
11
|
+
mergechannels/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
mergechannels-0.4.0.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
mergechannels-0.3.0.dist-info/METADATA,sha256=5KI3P3u9O0prtayGxavf_PooNdXYHHnyLp_fjrgW1Pw,5725
|
|
2
|
-
mergechannels-0.3.0.dist-info/WHEEL,sha256=8qbut5OV21MVsJh-6koZCKZnnuRHvhBkNK3ct3shD1c,107
|
|
3
|
-
mergechannels-0.3.0.dist-info/licenses/LICENSE,sha256=csvD60rgtSorbYEM3f8867qNyPCzmIXyFNj8h01Bd6c,1071
|
|
4
|
-
mergechannels.libs/libgcc_s-5b5488a6.so.1,sha256=HGKUsVmTeNAxEdSy7Ua5Vh_I9FN3RCbPWzvZ7H_TrwE,2749061
|
|
5
|
-
mergechannels/__init__.py,sha256=TTNiDGOOJ6_-yR-qvX_nXph646Sz6-MEORc8ItksCRE,232
|
|
6
|
-
mergechannels/__init__.pyi,sha256=tiDx6v14J0cedFdk6fzVRRyA21b4Z8eB_rtSTUjI804,749
|
|
7
|
-
mergechannels/_blending.py,sha256=mE5Cr9wvVJRcwfymg_UUZUjdIKx2mldfLU8QJT95bVM,84
|
|
8
|
-
mergechannels/_internal.py,sha256=ZcdBUFEq8k2Ve_ASOZLTuPBaFEEPqadc9LqAGmBqOas,1773
|
|
9
|
-
mergechannels/_luts.py,sha256=RswhkrCGAFtDthmVHt-Kk7lxROwS-kdsQy1EboyUUc8,3009
|
|
10
|
-
mergechannels/mergechannels.cpython-313-arm-linux-musleabihf.so,sha256=Xe8MZJb541OTiHF8xZFZ6T5Sty6kAzmp8UMQDILKHXE,1157721
|
|
11
|
-
mergechannels/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
mergechannels-0.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|