mergechannels 0.1.0__tar.gz → 0.1.1__tar.gz

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.

Files changed (174) hide show
  1. mergechannels-0.1.1/.gitattributes +7 -0
  2. {mergechannels-0.1.0 → mergechannels-0.1.1}/Cargo.lock +1 -1
  3. {mergechannels-0.1.0 → mergechannels-0.1.1}/Cargo.toml +1 -1
  4. mergechannels-0.1.1/PKG-INFO +112 -0
  5. mergechannels-0.1.1/README.md +93 -0
  6. mergechannels-0.1.1/assets/readme_images/camera_red-green.png +3 -0
  7. mergechannels-0.1.1/assets/readme_images/cells_multicolor.png +3 -0
  8. {mergechannels-0.1.0 → mergechannels-0.1.1}/pyproject.toml +8 -0
  9. {mergechannels-0.1.0 → mergechannels-0.1.1}/python/mergechannels/__init__.pyi +7 -1
  10. {mergechannels-0.1.0 → mergechannels-0.1.1}/python/mergechannels/_internal.py +14 -12
  11. {mergechannels-0.1.0 → mergechannels-0.1.1}/src/interface.rs +0 -6
  12. mergechannels-0.1.1/test.ipynb +101 -0
  13. mergechannels-0.1.0/PKG-INFO +0 -63
  14. mergechannels-0.1.0/README.md +0 -52
  15. mergechannels-0.1.0/test.ipynb +0 -262
  16. {mergechannels-0.1.0 → mergechannels-0.1.1}/.github/workflows/CI.yml +0 -0
  17. {mergechannels-0.1.0 → mergechannels-0.1.1}/.gitignore +0 -0
  18. {mergechannels-0.1.0 → mergechannels-0.1.1}/LICENSE +0 -0
  19. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/16_colors.lut +0 -0
  20. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/5_ramps.lut +0 -0
  21. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/6_shades.lut +0 -0
  22. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/Cyan Hot.lut +0 -0
  23. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/Green Fire Blue.lut +0 -0
  24. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/HiLo.lut +0 -0
  25. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/ICA.lut +0 -0
  26. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/ICA2.lut +0 -0
  27. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/ICA3.lut +0 -0
  28. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/Magenta Hot.lut +0 -0
  29. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/Orange Hot.lut +0 -0
  30. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/Rainbow RGB.lut +0 -0
  31. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/Red Hot.lut +0 -0
  32. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/Thermal.lut +0 -0
  33. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/Yellow Hot.lut +0 -0
  34. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/blue_orange_icb.lut +0 -0
  35. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/brgbcmyw.lut +0 -0
  36. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/cool.lut +0 -0
  37. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/edges.lut +0 -0
  38. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/gem.lut +0 -0
  39. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/glasbey.lut +0 -0
  40. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/glasbey_inverted.lut +0 -0
  41. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/glasbey_on_dark.lut +0 -0
  42. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/glow.lut +0 -0
  43. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/mpl-inferno.lut +0 -0
  44. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/mpl-magma.lut +0 -0
  45. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/mpl-plasma.lut +0 -0
  46. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/mpl-viridis.lut +0 -0
  47. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/phase.lut +0 -0
  48. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/physics.lut +0 -0
  49. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/royal.lut +0 -0
  50. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/sepia.lut +0 -0
  51. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/smart.lut +0 -0
  52. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/thal.lut +0 -0
  53. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/thallium.lut +0 -0
  54. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/builtin_luts/unionjack.lut +0 -0
  55. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/3color-BMR.lut +0 -0
  56. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/3color-CGY.lut +0 -0
  57. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/3color-RMB.lut +0 -0
  58. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/3color-YGC.lut +0 -0
  59. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/BOP blue.lut +0 -0
  60. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/BOP orange.lut +0 -0
  61. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/BOP purple.lut +0 -0
  62. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/I Blue.lut +0 -0
  63. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/I Bordeaux.lut +0 -0
  64. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/I Cyan.lut +0 -0
  65. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/I Forest.lut +0 -0
  66. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/I Green.lut +0 -0
  67. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/I Magenta.lut +0 -0
  68. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/I Purple.lut +0 -0
  69. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/I Red.lut +0 -0
  70. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/I Yellow.lut +0 -0
  71. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/NOTICE +0 -0
  72. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/OPF fresh.lut +0 -0
  73. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/OPF orange.lut +0 -0
  74. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/OPF purple.lut +0 -0
  75. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/christ_luts/Turbo.lut +0 -0
  76. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/16_colors.txt +0 -0
  77. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/3-3-2 RGB.txt +0 -0
  78. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/3color-BMR.txt +0 -0
  79. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/3color-CGY.txt +0 -0
  80. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/3color-RMB.txt +0 -0
  81. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/3color-YGC.txt +0 -0
  82. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/5_ramps.txt +0 -0
  83. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/6_shades.txt +0 -0
  84. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/BOP blue.txt +0 -0
  85. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/BOP orange.txt +0 -0
  86. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/BOP purple.txt +0 -0
  87. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Blue.txt +0 -0
  88. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Cyan Hot.txt +0 -0
  89. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Cyan.txt +0 -0
  90. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Fire.txt +0 -0
  91. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Grays.txt +0 -0
  92. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Green Fire Blue.txt +0 -0
  93. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Green.txt +0 -0
  94. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/HiLo.txt +0 -0
  95. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/I Blue.txt +0 -0
  96. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/I Bordeaux.txt +0 -0
  97. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/I Cyan.txt +0 -0
  98. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/I Forest.txt +0 -0
  99. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/I Green.txt +0 -0
  100. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/I Magenta.txt +0 -0
  101. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/I Purple.txt +0 -0
  102. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/I Red.txt +0 -0
  103. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/I Yellow.txt +0 -0
  104. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/ICA.txt +0 -0
  105. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/ICA2.txt +0 -0
  106. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/ICA3.txt +0 -0
  107. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Ice.txt +0 -0
  108. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Magenta Hot.txt +0 -0
  109. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Magenta.txt +0 -0
  110. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/OIMB1.txt +0 -0
  111. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/OIMB2.txt +0 -0
  112. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/OIMB3.txt +0 -0
  113. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/OPF fresh.txt +0 -0
  114. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/OPF orange.txt +0 -0
  115. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/OPF purple.txt +0 -0
  116. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Orange Hot.txt +0 -0
  117. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Rainbow RGB.txt +0 -0
  118. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Red Hot.txt +0 -0
  119. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Red%Green.txt +0 -0
  120. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Red.txt +0 -0
  121. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Spectrum.txt +0 -0
  122. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Thermal.txt +0 -0
  123. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Turbo.txt +0 -0
  124. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Yellow Hot.txt +0 -0
  125. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/Yellow.txt +0 -0
  126. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/betterBlue.txt +0 -0
  127. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/betterCyan.txt +0 -0
  128. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/betterGreen.txt +0 -0
  129. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/betterOrange.txt +0 -0
  130. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/betterRed.txt +0 -0
  131. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/betterYellow.txt +0 -0
  132. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/blue_orange_icb.txt +0 -0
  133. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/brgbcmyw.txt +0 -0
  134. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/cool.txt +0 -0
  135. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/edges.txt +0 -0
  136. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/gem.txt +0 -0
  137. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/glasbey.txt +0 -0
  138. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/glasbey_inverted.txt +0 -0
  139. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/glasbey_on_dark.txt +0 -0
  140. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/glow.txt +0 -0
  141. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/mpl-inferno.txt +0 -0
  142. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/mpl-magma.txt +0 -0
  143. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/mpl-plasma.txt +0 -0
  144. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/mpl-viridis.txt +0 -0
  145. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/phase.txt +0 -0
  146. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/physics.txt +0 -0
  147. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/royal.txt +0 -0
  148. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/sepia.txt +0 -0
  149. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/smart.txt +0 -0
  150. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/thal.txt +0 -0
  151. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/thallium.txt +0 -0
  152. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/converted/unionjack.txt +0 -0
  153. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/zac_luts/OIMB1.lut +0 -0
  154. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/zac_luts/OIMB2.lut +0 -0
  155. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/zac_luts/OIMB3.lut +0 -0
  156. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/zac_luts/betterBlue.lut +0 -0
  157. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/zac_luts/betterCyan.lut +0 -0
  158. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/zac_luts/betterGreen.lut +0 -0
  159. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/zac_luts/betterOrange.lut +0 -0
  160. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/zac_luts/betterRed.lut +0 -0
  161. {mergechannels-0.1.0 → mergechannels-0.1.1}/assets/zac_luts/betterYellow.lut +0 -0
  162. {mergechannels-0.1.0 → mergechannels-0.1.1}/pytests/test_colorize.py +0 -0
  163. {mergechannels-0.1.0 → mergechannels-0.1.1}/python/mergechannels/__init__.py +0 -0
  164. {mergechannels-0.1.0 → mergechannels-0.1.1}/python/mergechannels/_blending.py +0 -0
  165. {mergechannels-0.1.0 → mergechannels-0.1.1}/python/mergechannels/_luts.py +0 -0
  166. {mergechannels-0.1.0 → mergechannels-0.1.1}/python/mergechannels/py.typed +0 -0
  167. {mergechannels-0.1.0 → mergechannels-0.1.1}/scripts/convert_luts_to_txt.ijm +0 -0
  168. {mergechannels-0.1.0 → mergechannels-0.1.1}/scripts/populate_luts.py +0 -0
  169. {mergechannels-0.1.0 → mergechannels-0.1.1}/src/blend.rs +0 -0
  170. {mergechannels-0.1.0 → mergechannels-0.1.1}/src/cmaps.rs +0 -0
  171. {mergechannels-0.1.0 → mergechannels-0.1.1}/src/colorize.rs +0 -0
  172. {mergechannels-0.1.0 → mergechannels-0.1.1}/src/lib.rs +0 -0
  173. {mergechannels-0.1.0 → mergechannels-0.1.1}/src/normalize.rs +0 -0
  174. {mergechannels-0.1.0 → mergechannels-0.1.1}/uv.lock +0 -0
@@ -0,0 +1,7 @@
1
+ # LFS for image files
2
+ *.png filter=lfs diff=lfs merge=lfs -text
3
+ *.jpg filter=lfs diff=lfs merge=lfs -text
4
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
5
+ *.gif filter=lfs diff=lfs merge=lfs -text
6
+ *.tif filter=lfs diff=lfs merge=lfs -text
7
+ *.tiff filter=lfs diff=lfs merge=lfs -text
@@ -59,7 +59,7 @@ dependencies = [
59
59
 
60
60
  [[package]]
61
61
  name = "mergechannels"
62
- version = "0.1.0"
62
+ version = "0.1.1"
63
63
  dependencies = [
64
64
  "lazy_static",
65
65
  "ndarray",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "mergechannels"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  edition = "2021"
5
5
 
6
6
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -0,0 +1,112 @@
1
+ Metadata-Version: 2.4
2
+ Name: mergechannels
3
+ Version: 0.1.1
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Requires-Dist: numpy>=1.24.4
15
+ License-File: LICENSE
16
+ License: MIT
17
+ Requires-Python: >=3.8, <3.13
18
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
19
+
20
+ [![CI](https://github.com/zacswider/mergechannels/actions/workflows/CI.yml/badge.svg)](https://github.com/zacswider/mergechannels/actions/workflows/CI.yml)
21
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
22
+ ![PyPI](https://img.shields.io/pypi/v/mergechannels)
23
+
24
+ # mergechannels
25
+
26
+ This project was originally conceived because I often find myself wanting to apply and blend colormaps to images while working from Python, and for historical reasons many of my favorite colormaps are distributed as [FIJI](https://imagej.net/software/fiji/) lookup tables. I also care about things likes speed and memory usage (e.g., not casting large arrays to floating point dtypes, not creating multiple whole arrays just to add them together), so I was interested in seeing if I could at least match matplotlib's colormapping performance with my own hand-rolled colorizer in Rust.
27
+
28
+
29
+
30
+ ## Installation
31
+
32
+ Install pre-compiled binaries from [PyPI](https://pypi.org/project/mergechannels/):
33
+ ```bash
34
+ pip install mergechannels
35
+ ```
36
+
37
+ Build from source on your own machine:
38
+ ```bash
39
+ pip install git+https://github.com/zacswider/mergechannels.git
40
+ ```
41
+
42
+ ## Usage
43
+ *NOTE*: scikit-image is not a dependency of this project, but is used in the examples below to fetch images.
44
+
45
+ ### colorize a single image
46
+
47
+ ```python
48
+ from skimage import data
49
+ import mergechannels as mc
50
+
51
+ img = data.camera()
52
+ colorized = mc.apply_color_map(img, 'Red/Green')
53
+ fig, axes = plt.subplots(1, 2, figsize=(6, 3), dpi=150)
54
+ for ax in axes: ax.axis('off')
55
+ (a, b) = axes
56
+ a.imshow(img, cmap='gray')
57
+ b.imshow(colorized)
58
+ plt.show()
59
+ print(colorized.shape, colorized.dtype)
60
+ >> (512, 512, 3) uint8
61
+ ```
62
+ ![colorize a single image](assets/readme_images/camera_red-green.png)
63
+
64
+
65
+ ### apply a different colormap to each channel
66
+ ```python
67
+ from skimage import data
68
+ import matplotlib.pyplot as plt
69
+ import mergechannels as mc
70
+
71
+ cells, nuclei = data.cells3d().max(axis=0)
72
+ cells = to_uint8(cells) # normalize your own arrays, mergechannels doesn't currently handle this
73
+ nuclei = to_uint8(nuclei) # normalize your own arrays, mergechannels doesn't currently handle this
74
+
75
+ fig, axes = plt.subplots(2, 2, figsize=(6, 6), dpi=150)
76
+ for ax in axes.ravel(): ax.axis('off')
77
+ (a, b, c, d) = axes.ravel()
78
+ a.imshow(cells, cmap='gray')
79
+ b.imshow(nuclei, cmap='gray')
80
+ c.imshow(
81
+ mc.merge(
82
+ [cells, nuclei],
83
+ ['Orange Hot', 'Cyan Hot'], # maximum blending is the default
84
+ ),
85
+ )
86
+ d.imshow(
87
+ mc.merge(
88
+ [cells, nuclei],
89
+ ['I Blue', 'I Forest'],
90
+ blending='min', # use minimum blending with inverted colormaps
91
+ ),
92
+ )
93
+ fig.tight_layout()
94
+ plt.show()
95
+ ```
96
+ ![apply a different colormap to each channel](assets/readme_images/cells_multicolor.png)
97
+
98
+
99
+ ## Roadmap
100
+ mergechannels is currently incredibly simple. It can apply one or more colormaps to one or more 2D 8-bit images and that's it.
101
+ - Add support for any numerical dtype
102
+ - Add support for 3D images
103
+ - Add option to return any colormap as a matplotlib colormap
104
+ - Add support for directly passing matplotlib colormaps instead of colormap names
105
+ - Parallelize colormap application on large images (if it's helpful)
106
+ - Add option to overlay binary or instance masks onto colorized images
107
+
108
+ ## Acknowledgements
109
+
110
+ There are other great colormapping libraries available (e.g., [microfilm](https://github.com/guiwitz/microfilm), [cmap](https://github.com/pyapp-kit/cmap)) that are more feature-rich than this one, but which don't address my goals. My hope is that this project can fill an un-met niche and otherwise maintain full compatibility with these and similar libraries.
111
+
112
+ This project incorporates a number of colormaps that were hand-crafted by Christophe Leterrier and were originally distributed here under the MIT license: https://github.com/cleterrier/ChrisLUTs
@@ -0,0 +1,93 @@
1
+ [![CI](https://github.com/zacswider/mergechannels/actions/workflows/CI.yml/badge.svg)](https://github.com/zacswider/mergechannels/actions/workflows/CI.yml)
2
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
3
+ ![PyPI](https://img.shields.io/pypi/v/mergechannels)
4
+
5
+ # mergechannels
6
+
7
+ This project was originally conceived because I often find myself wanting to apply and blend colormaps to images while working from Python, and for historical reasons many of my favorite colormaps are distributed as [FIJI](https://imagej.net/software/fiji/) lookup tables. I also care about things likes speed and memory usage (e.g., not casting large arrays to floating point dtypes, not creating multiple whole arrays just to add them together), so I was interested in seeing if I could at least match matplotlib's colormapping performance with my own hand-rolled colorizer in Rust.
8
+
9
+
10
+
11
+ ## Installation
12
+
13
+ Install pre-compiled binaries from [PyPI](https://pypi.org/project/mergechannels/):
14
+ ```bash
15
+ pip install mergechannels
16
+ ```
17
+
18
+ Build from source on your own machine:
19
+ ```bash
20
+ pip install git+https://github.com/zacswider/mergechannels.git
21
+ ```
22
+
23
+ ## Usage
24
+ *NOTE*: scikit-image is not a dependency of this project, but is used in the examples below to fetch images.
25
+
26
+ ### colorize a single image
27
+
28
+ ```python
29
+ from skimage import data
30
+ import mergechannels as mc
31
+
32
+ img = data.camera()
33
+ colorized = mc.apply_color_map(img, 'Red/Green')
34
+ fig, axes = plt.subplots(1, 2, figsize=(6, 3), dpi=150)
35
+ for ax in axes: ax.axis('off')
36
+ (a, b) = axes
37
+ a.imshow(img, cmap='gray')
38
+ b.imshow(colorized)
39
+ plt.show()
40
+ print(colorized.shape, colorized.dtype)
41
+ >> (512, 512, 3) uint8
42
+ ```
43
+ ![colorize a single image](assets/readme_images/camera_red-green.png)
44
+
45
+
46
+ ### apply a different colormap to each channel
47
+ ```python
48
+ from skimage import data
49
+ import matplotlib.pyplot as plt
50
+ import mergechannels as mc
51
+
52
+ cells, nuclei = data.cells3d().max(axis=0)
53
+ cells = to_uint8(cells) # normalize your own arrays, mergechannels doesn't currently handle this
54
+ nuclei = to_uint8(nuclei) # normalize your own arrays, mergechannels doesn't currently handle this
55
+
56
+ fig, axes = plt.subplots(2, 2, figsize=(6, 6), dpi=150)
57
+ for ax in axes.ravel(): ax.axis('off')
58
+ (a, b, c, d) = axes.ravel()
59
+ a.imshow(cells, cmap='gray')
60
+ b.imshow(nuclei, cmap='gray')
61
+ c.imshow(
62
+ mc.merge(
63
+ [cells, nuclei],
64
+ ['Orange Hot', 'Cyan Hot'], # maximum blending is the default
65
+ ),
66
+ )
67
+ d.imshow(
68
+ mc.merge(
69
+ [cells, nuclei],
70
+ ['I Blue', 'I Forest'],
71
+ blending='min', # use minimum blending with inverted colormaps
72
+ ),
73
+ )
74
+ fig.tight_layout()
75
+ plt.show()
76
+ ```
77
+ ![apply a different colormap to each channel](assets/readme_images/cells_multicolor.png)
78
+
79
+
80
+ ## Roadmap
81
+ mergechannels is currently incredibly simple. It can apply one or more colormaps to one or more 2D 8-bit images and that's it.
82
+ - Add support for any numerical dtype
83
+ - Add support for 3D images
84
+ - Add option to return any colormap as a matplotlib colormap
85
+ - Add support for directly passing matplotlib colormaps instead of colormap names
86
+ - Parallelize colormap application on large images (if it's helpful)
87
+ - Add option to overlay binary or instance masks onto colorized images
88
+
89
+ ## Acknowledgements
90
+
91
+ There are other great colormapping libraries available (e.g., [microfilm](https://github.com/guiwitz/microfilm), [cmap](https://github.com/pyapp-kit/cmap)) that are more feature-rich than this one, but which don't address my goals. My hope is that this project can fill an un-met niche and otherwise maintain full compatibility with these and similar libraries.
92
+
93
+ This project incorporates a number of colormaps that were hand-crafted by Christophe Leterrier and were originally distributed here under the MIT license: https://github.com/cleterrier/ChrisLUTs
@@ -0,0 +1,3 @@
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1834bf0e964d272de7d6788f2569f5159f6a0180472c27fd77b5e90f34baa45d
3
+ size 563632
@@ -0,0 +1,3 @@
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c02bd422ad5be0c12c62fe6c2776799ffe8c237e0e50af1c10f470ae691100b7
3
+ size 892784
@@ -4,11 +4,19 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "mergechannels"
7
+ license = { text = "MIT" }
7
8
  requires-python = ">=3.8, <3.13"
8
9
  classifiers = [
9
10
  "Programming Language :: Rust",
10
11
  "Programming Language :: Python :: Implementation :: CPython",
11
12
  "Programming Language :: Python :: Implementation :: PyPy",
13
+ "License :: OSI Approved :: MIT License",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.8",
16
+ "Programming Language :: Python :: 3.9",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
12
20
  ]
13
21
  dynamic = ["version"]
14
22
  dependencies = ["numpy>=1.24.4"]
@@ -9,13 +9,19 @@ def merge(
9
9
  arrs: Sequence[np.ndarray],
10
10
  colors: Sequence[COLORMAPS] = (),
11
11
  blending: Literal[BLENDING_OPTIONS] = 'max',
12
+ saturation_limits: tuple[float, float] = (0.2, 99.8),
12
13
  ) -> np.ndarray:
13
14
  ...
14
15
 
15
- def apply_color_map(arr: np.ndarray, cmap_name: COLORMAPS) -> np.ndarray: ...
16
+ def apply_color_map(
17
+ arr: np.ndarray,
18
+ cmap_name: COLORMAPS,
19
+ saturation_limits: tuple[float, float] = (0.2, 99.8),
20
+ ) -> np.ndarray: ...
16
21
 
17
22
  def apply_colors_and_merge_nc(
18
23
  arrs: Sequence[np.ndarray],
19
24
  colors: Sequence[COLORMAPS] = (),
20
25
  blending: Literal[BLENDING_OPTIONS] = 'max',
26
+ saturation_limits: Sequence[tuple[float, float]] = (),
21
27
  ) -> np.ndarray: ...
@@ -11,24 +11,16 @@ from ._blending import BLENDING_OPTIONS
11
11
 
12
12
  def merge(
13
13
  arrs: Sequence[np.ndarray],
14
- colors: Sequence[COLORMAPS] = (),
14
+ colors: Sequence[COLORMAPS],
15
15
  blending: BLENDING_OPTIONS = 'max',
16
16
  ) -> np.ndarray:
17
17
  '''
18
18
  apply cmaps to arrays and blend the colors
19
19
  '''
20
+ # region validation
20
21
  n_arrs = len(arrs)
21
22
  n_colors = len(colors)
22
- if n_arrs > 0 and n_colors == 0:
23
- arr_shapes = [arr.shape for arr in arrs]
24
- if not all([len(arr_shape) == 3 for arr_shape in arr_shapes]):
25
- raise ValueError(
26
- 'Expected a sequence of pre-colorized arrays, '
27
- f'got {n_arrs} arrays of shapes {arr_shapes}'
28
- )
29
- # call merge rgb arrs here
30
- return np.zeros((3,3))
31
- if not n_arrs == n_colors:
23
+ if not n_arrs == n_colors and n_arrs > 0:
32
24
  raise ValueError(
33
25
  'Expected an equal number of arrays to colorize and colormap names to apply. '
34
26
  f'Got {n_arrs} arrays and {n_colors} colors'
@@ -38,7 +30,17 @@ def merge(
38
30
  raise ValueError(
39
31
  f'Expected every array to have the same shape, got {arr_shapes}'
40
32
  )
41
- # call apply and merge rgb arrs here
33
+ if not len(arr_shapes[0]) == 2:
34
+ raise ValueError(
35
+ f'Expected every array to be 2D, got {arr_shapes[0]}'
36
+ )
37
+ arr_dtypes = [arr.dtype for arr in arrs]
38
+ if not len(set(arr_dtypes)) == 1:
39
+ raise ValueError(
40
+ f'Expected every array to have the same dtype, got {arr_dtypes}'
41
+ )
42
+ # endregion
43
+
42
44
  match n_arrs:
43
45
  case 1:
44
46
  return apply_color_map(arr=arrs[0], cmap_name=colors[0])
@@ -12,12 +12,6 @@ pub fn apply_color_map_py<'py>(
12
12
  arr: PyReadonlyArray2<'py, u8>,
13
13
  cmap_name: &str,
14
14
  ) -> Bound<'py, PyArray3<u8>> {
15
- // Get the ndarray::ArrayView
16
- // let array_view: ArrayView = arr.as_array();
17
-
18
- // Get the dtype
19
- // let dtype = array_view.dtype();
20
- // println!("{dtype}");
21
15
  let arr = arr.as_array();
22
16
  let cmap = cmaps::load_cmap(cmap_name);
23
17
  let rgb = colorize::apply_color_map(arr, cmap);
@@ -0,0 +1,101 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "%load_ext autoreload\n",
10
+ "%autoreload 2"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": null,
16
+ "metadata": {},
17
+ "outputs": [],
18
+ "source": [
19
+ "import numpy as np\n",
20
+ "from skimage import data\n",
21
+ "from matplotlib import pyplot as plt\n",
22
+ "\n",
23
+ "def to_uint8(arr):\n",
24
+ " return (arr * 255).astype('uint8')\n",
25
+ "\n",
26
+ "cells, nuclei = data.cells3d().max(axis=0)\n",
27
+ "cells = to_uint8(cells / cells.max())\n",
28
+ "nuclei = to_uint8(nuclei / nuclei.max())\n",
29
+ "fig, (a, b, c) = plt.subplots(1, 3)\n",
30
+ "a.imshow(cells, cmap='gray')\n",
31
+ "b.imshow(nuclei, cmap='gray')\n",
32
+ "\n",
33
+ "import mergechannels as mc\n",
34
+ "c.imshow(mc.merge([cells, nuclei], ['Orange Hot', 'Cyan Hot']))"
35
+ ]
36
+ },
37
+ {
38
+ "cell_type": "code",
39
+ "execution_count": null,
40
+ "metadata": {},
41
+ "outputs": [],
42
+ "source": [
43
+ "cells.dtype"
44
+ ]
45
+ },
46
+ {
47
+ "cell_type": "code",
48
+ "execution_count": null,
49
+ "metadata": {},
50
+ "outputs": [],
51
+ "source": []
52
+ },
53
+ {
54
+ "cell_type": "code",
55
+ "execution_count": 4,
56
+ "metadata": {},
57
+ "outputs": [],
58
+ "source": [
59
+ "import sys\n",
60
+ "sys.stdout.flush()"
61
+ ]
62
+ },
63
+ {
64
+ "cell_type": "code",
65
+ "execution_count": null,
66
+ "metadata": {},
67
+ "outputs": [],
68
+ "source": [
69
+ "x"
70
+ ]
71
+ },
72
+ {
73
+ "cell_type": "code",
74
+ "execution_count": null,
75
+ "metadata": {},
76
+ "outputs": [],
77
+ "source": []
78
+ }
79
+ ],
80
+ "metadata": {
81
+ "kernelspec": {
82
+ "display_name": ".venv",
83
+ "language": "python",
84
+ "name": "python3"
85
+ },
86
+ "language_info": {
87
+ "codemirror_mode": {
88
+ "name": "ipython",
89
+ "version": 3
90
+ },
91
+ "file_extension": ".py",
92
+ "mimetype": "text/x-python",
93
+ "name": "python",
94
+ "nbconvert_exporter": "python",
95
+ "pygments_lexer": "ipython3",
96
+ "version": "3.11.9"
97
+ }
98
+ },
99
+ "nbformat": 4,
100
+ "nbformat_minor": 2
101
+ }
@@ -1,63 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: mergechannels
3
- Version: 0.1.0
4
- Classifier: Programming Language :: Rust
5
- Classifier: Programming Language :: Python :: Implementation :: CPython
6
- Classifier: Programming Language :: Python :: Implementation :: PyPy
7
- Requires-Dist: numpy>=1.24.4
8
- License-File: LICENSE
9
- Requires-Python: >=3.8, <3.13
10
- Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
11
-
12
- # mergechannels
13
-
14
- This project was originally conceived because I often find myself wanting to apply and blend colormaps to images while working from Python, and for historical reasons many of my favorite colormaps are distributed as [FIJI](https://imagej.net/software/fiji/) lookup tables. I also care about things likes speed and memory usage (e.g., not casting large arrays to floating point dtypes), so I was interested in seeing if I could at least match matplotlib's colormapping performance with my own hand-rolled colorizer in Rust.
15
-
16
- There are other great colormapping libraries available (e.g., [microfilm](https://github.com/guiwitz/microfilm), [cmap](https://github.com/pyapp-kit/cmap)) that are more feature-rich than this projecting on your needs, but which don't address the my goals. My hope is that this project can fill and un-met niche and otherwise maintain full compatibility with these and similar libraries.
17
-
18
- ## Installation
19
-
20
- Install pre-compiled binaries from [PyPI](https://pypi.org/project/mergechannels/):
21
- ```bash
22
- pip install mergechannels
23
- ```
24
-
25
- Build from source on your own machine:
26
- ```bash
27
- pip install git+https://github.com/zacswider/mergechannels.git
28
- ```
29
-
30
- ## Usage
31
- *NOTE*: scikit-image is not a dependency of this project, but is used in the examples below to fetch images.
32
-
33
- ### colorize a single image
34
-
35
- ```python
36
- from skimage import data
37
- import matplotlib.pyplot as plt
38
- import mergechannels as mc
39
-
40
- img = data.camera()
41
- fig, ax = plt.subplots()
42
- ax.imshow(mc.apply_colormap(img, 'Orange Hot'))
43
- ```
44
-
45
- ### apply a different colormap to each channel
46
- ```python
47
- from skimage import data
48
- import matplotlib.pyplot as plt
49
- import mergechannels as mc
50
-
51
- cells, nuclei = data.cells3d().max(axis=0)
52
- cells = to_uint8(cells / cells.max()) <- broken until normalization is handled
53
- nuclei = to_uint8(nuclei / nuclei.max()) <- broken until normalization is handled
54
- fig, (a, b, c) = plt.subplots(1, 3)
55
- a.imshow(cells, cmap='gray')
56
- b.imshow(nuclei, cmap='gray')
57
-
58
- import mergechannels as mc
59
- c.imshow(mc.merge([cells, nuclei], ['Orange Hot', 'Cyan Hot']))
60
- ```
61
-
62
- ## Acknowledgements
63
- This project incorporates a number of colormaps that were hand-crafted by Christophe Leterrier and were originally distributed here under the MIT license: https://github.com/cleterrier/ChrisLUTs
@@ -1,52 +0,0 @@
1
- # mergechannels
2
-
3
- This project was originally conceived because I often find myself wanting to apply and blend colormaps to images while working from Python, and for historical reasons many of my favorite colormaps are distributed as [FIJI](https://imagej.net/software/fiji/) lookup tables. I also care about things likes speed and memory usage (e.g., not casting large arrays to floating point dtypes), so I was interested in seeing if I could at least match matplotlib's colormapping performance with my own hand-rolled colorizer in Rust.
4
-
5
- There are other great colormapping libraries available (e.g., [microfilm](https://github.com/guiwitz/microfilm), [cmap](https://github.com/pyapp-kit/cmap)) that are more feature-rich than this projecting on your needs, but which don't address the my goals. My hope is that this project can fill and un-met niche and otherwise maintain full compatibility with these and similar libraries.
6
-
7
- ## Installation
8
-
9
- Install pre-compiled binaries from [PyPI](https://pypi.org/project/mergechannels/):
10
- ```bash
11
- pip install mergechannels
12
- ```
13
-
14
- Build from source on your own machine:
15
- ```bash
16
- pip install git+https://github.com/zacswider/mergechannels.git
17
- ```
18
-
19
- ## Usage
20
- *NOTE*: scikit-image is not a dependency of this project, but is used in the examples below to fetch images.
21
-
22
- ### colorize a single image
23
-
24
- ```python
25
- from skimage import data
26
- import matplotlib.pyplot as plt
27
- import mergechannels as mc
28
-
29
- img = data.camera()
30
- fig, ax = plt.subplots()
31
- ax.imshow(mc.apply_colormap(img, 'Orange Hot'))
32
- ```
33
-
34
- ### apply a different colormap to each channel
35
- ```python
36
- from skimage import data
37
- import matplotlib.pyplot as plt
38
- import mergechannels as mc
39
-
40
- cells, nuclei = data.cells3d().max(axis=0)
41
- cells = to_uint8(cells / cells.max()) <- broken until normalization is handled
42
- nuclei = to_uint8(nuclei / nuclei.max()) <- broken until normalization is handled
43
- fig, (a, b, c) = plt.subplots(1, 3)
44
- a.imshow(cells, cmap='gray')
45
- b.imshow(nuclei, cmap='gray')
46
-
47
- import mergechannels as mc
48
- c.imshow(mc.merge([cells, nuclei], ['Orange Hot', 'Cyan Hot']))
49
- ```
50
-
51
- ## Acknowledgements
52
- This project incorporates a number of colormaps that were hand-crafted by Christophe Leterrier and were originally distributed here under the MIT license: https://github.com/cleterrier/ChrisLUTs