batoolset 0.1.8__tar.gz → 0.1.9__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.
Files changed (171) hide show
  1. {batoolset-0.1.8 → batoolset-0.1.9}/PKG-INFO +1 -1
  2. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/luts/lut_minimal_test.py +71 -26
  3. batoolset-0.1.9/batoolset/luts/lutcreatorfromformula.py +204 -0
  4. batoolset-0.1.9/batoolset/luts/luteditor.py +116 -0
  5. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/pyqts/tools.py +38 -2
  6. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/version.py +1 -1
  7. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset.egg-info/PKG-INFO +1 -1
  8. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset.egg-info/SOURCES.txt +2 -0
  9. {batoolset-0.1.8 → batoolset-0.1.9}/LICENSE +0 -0
  10. {batoolset-0.1.8 → batoolset-0.1.9}/README.md +0 -0
  11. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/GUI/__init__.py +0 -0
  12. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/GUI/list_gui.py +0 -0
  13. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/GUI/multi_image_display.py +0 -0
  14. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/GUI/open.py +0 -0
  15. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/GUI/overlay_hints.py +0 -0
  16. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/GUI/paint2.py +0 -0
  17. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/GUI/scrollablepaint.py +0 -0
  18. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/IJ_ROIs/__init__.py +0 -0
  19. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/IJ_ROIs/tools.py +0 -0
  20. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/SQLites/__init__.py +0 -0
  21. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/SQLites/tools.py +0 -0
  22. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/__init__.py +0 -0
  23. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/binaries/__init__.py +0 -0
  24. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/binaries/tools.py +0 -0
  25. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/clipboards/__init__.py +0 -0
  26. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/clipboards/tools.py +0 -0
  27. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/colors/__init__.py +0 -0
  28. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/colors/colorgen.py +0 -0
  29. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/colors/tools.py +0 -0
  30. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/command_line/__init__.py +0 -0
  31. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/command_line/tools.py +0 -0
  32. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/dialogs/__init__.py +0 -0
  33. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/dialogs/opensave.py +0 -0
  34. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/dicts/__init__.py +0 -0
  35. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/dicts/tools.py +0 -0
  36. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/dims/__init__.py +0 -0
  37. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/dims/tools.py +0 -0
  38. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/__init__.py +0 -0
  39. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/Position.py +0 -0
  40. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/__init__.py +0 -0
  41. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/automated_alignment_drawing_refactored.py +0 -0
  42. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/circle2d.py +0 -0
  43. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/compute_optimal_size_all_merged.py +0 -0
  44. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/ellipse2d.py +0 -0
  45. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/freehand2d.py +0 -0
  46. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/group.py +0 -0
  47. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/image2d.py +0 -0
  48. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/line2d.py +0 -0
  49. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/point2d.py +0 -0
  50. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/polygon2d.py +0 -0
  51. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/polyline2d.py +0 -0
  52. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/rect2d.py +0 -0
  53. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/rectangle2d.py +0 -0
  54. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/scalebar.py +0 -0
  55. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/serializablefont.py +0 -0
  56. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/serializableguiparams.py +0 -0
  57. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/square2d.py +0 -0
  58. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/textorientation.py +0 -0
  59. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/tools.py +0 -0
  60. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/transform2D.py +0 -0
  61. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/shapes/txt2d.py +0 -0
  62. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/widgets/__init__.py +0 -0
  63. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/widgets/col.py +0 -0
  64. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/widgets/image_group.py +0 -0
  65. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/widgets/image_organizer.py +0 -0
  66. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/widgets/paint.py +0 -0
  67. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/drawings/widgets/vectorial.py +0 -0
  68. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/figure/__init__.py +0 -0
  69. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/figure/alignment.py +0 -0
  70. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/figure/column.py +0 -0
  71. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/figure/fig_tools.py +0 -0
  72. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/figure/minimal_debugger_scale_etc.py +0 -0
  73. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/figure/panel.py +0 -0
  74. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/figure/row.py +0 -0
  75. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/figure/user_selection.py +0 -0
  76. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/files/__init__.py +0 -0
  77. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/files/tools.py +0 -0
  78. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/images/__init__.py +0 -0
  79. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/images/centralstore.py +0 -0
  80. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/images/tools.py +0 -0
  81. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/img.py +0 -0
  82. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/javas/__init__.py +0 -0
  83. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/javas/tools.py +0 -0
  84. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/linux/__init__.py +0 -0
  85. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/linux/tools.py +0 -0
  86. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/lists/__init__.py +0 -0
  87. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/lists/tools.py +0 -0
  88. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/luts/__init__.py +0 -0
  89. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/matplolibs/__init__.py +0 -0
  90. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/matplolibs/tools.py +0 -0
  91. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/nps/__init__.py +0 -0
  92. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/nps/tools.py +0 -0
  93. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/pandaz/__init__.py +0 -0
  94. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/pandaz/tools.py +0 -0
  95. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/partials/__init__.py +0 -0
  96. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/partials/tools.py +0 -0
  97. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/paths/__init__.py +0 -0
  98. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/paths/tools.py +0 -0
  99. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/plots/__init__.py +0 -0
  100. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/plots/tools.py +0 -0
  101. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/pyqts/__init__.py +0 -0
  102. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/pyqts/pleasewaitdialog.py +0 -0
  103. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/res/__init__.py +0 -0
  104. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/res/tools.py +0 -0
  105. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/serializations/__init__.py +0 -0
  106. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/serializations/tools.py +0 -0
  107. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/sets/__init__.py +0 -0
  108. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/sets/tools.py +0 -0
  109. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/settings/__init__.py +0 -0
  110. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/settings/global_settings.py +0 -0
  111. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/strings/__init__.py +0 -0
  112. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/strings/tools.py +0 -0
  113. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/__init__.py +0 -0
  114. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/database/__init__.py +0 -0
  115. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/database/advanced_sql_plotter.py +0 -0
  116. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/database/my_qt_table.py +0 -0
  117. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/database/preview_and_edit_sqlite_db.py +0 -0
  118. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/database/sql.py +0 -0
  119. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/database/sql_column_name_dialog.py +0 -0
  120. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/measurements/TAmeasures.py +0 -0
  121. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/measurements/__init__.py +0 -0
  122. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/measurements/measurements3D/__init__.py +0 -0
  123. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/measurements/measurements3D/get_point_on_surface_if_centroid_is_bad.py +0 -0
  124. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/measurements/measurements3D/height_map_to_projection.py +0 -0
  125. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/measurements/measurements3D/measures3D.py +0 -0
  126. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/measurements/measurements3D/triangulate.py +0 -0
  127. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/measurements/nematic.py +0 -0
  128. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/measurements/nematic_measurements.py +0 -0
  129. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/segmentation/__init__.py +0 -0
  130. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/segmentation/neo_wshed.py +0 -0
  131. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/selections/__init__.py +0 -0
  132. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/selections/selection.py +0 -0
  133. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/tracking/__init__.py +0 -0
  134. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/tracking/last_tracking_based_on_matching_or_on_translation_from_mermaid_warp.py +0 -0
  135. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/tracking/local_to_track_correspondance.py +0 -0
  136. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/tracking/rapid_detection_of_vertices.py +0 -0
  137. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/tracking/registration.py +0 -0
  138. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/tracking/swap_detector_and_fixer.py +0 -0
  139. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/tracking/track_correction.py +0 -0
  140. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/tracking/tracking_error_detector_and_fixer.py +0 -0
  141. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/tracking/tracking_yet_another_approach_pyramidal_registration_n_neo_swapping_correction.py +0 -0
  142. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/utils/TA_tools.py +0 -0
  143. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/utils/__init__.py +0 -0
  144. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/ta/utils/rps_tools.py +0 -0
  145. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/tests/__init__.py +0 -0
  146. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/tests/rps_tools.py +0 -0
  147. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/tests/tools.py +0 -0
  148. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/tools/__init__.py +0 -0
  149. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/tools/early_stopper_class.py +0 -0
  150. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/tools/guided_data_recoverer.py +0 -0
  151. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/tools/logger.py +0 -0
  152. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/tools/mytimer.py +0 -0
  153. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/tools/prompt_color.py +0 -0
  154. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/tools/qthandler.py +0 -0
  155. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/uis/__init__.py +0 -0
  156. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/uis/blinker.py +0 -0
  157. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/unsafe/__init__.py +0 -0
  158. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/unsafe/tools.py +0 -0
  159. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/utils/__init__.py +0 -0
  160. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/utils/commontools.py +0 -0
  161. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/utils/loadlist.py +0 -0
  162. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/xmls/__init__.py +0 -0
  163. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/xmls/tools.py +0 -0
  164. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/zarrs/__init__.py +0 -0
  165. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/zips/__init__.py +0 -0
  166. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset/zips/tools.py +0 -0
  167. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset.egg-info/dependency_links.txt +0 -0
  168. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset.egg-info/requires.txt +0 -0
  169. {batoolset-0.1.8 → batoolset-0.1.9}/batoolset.egg-info/top_level.txt +0 -0
  170. {batoolset-0.1.8 → batoolset-0.1.9}/setup.cfg +0 -0
  171. {batoolset-0.1.8 → batoolset-0.1.9}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: batoolset
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: An aggregate of functions I find useful
5
5
  Home-page: https://github.com/baigouy/batoolset
6
6
  Author: Benoit Aigouy
@@ -11,6 +11,7 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg
11
11
  from matplotlib.figure import Figure
12
12
  from batoolset.img import fig_to_numpy
13
13
  import base64
14
+ import numexpr as ne
14
15
 
15
16
  def serialize_lut(lut_256_3):
16
17
  # see also /home/aigouy/mon_prog/Python/epyseg_pkg/personal/FigGen_EzFig2/trash/tst_base64_encode_the_whole_np_array.py
@@ -142,11 +143,10 @@ def list_available_luts(return_matplotlib_lib_luts_in_separate_database=False):
142
143
  """
143
144
  hash_pal = {
144
145
  "DEFAULT": "22,13,-23",
145
- "GREEN": "0,3,0",
146
146
  "RED": "3,0,0",
147
+ "GREEN": "0,3,0",
147
148
  "BLUE": "0,0,3",
148
149
  "GRAY": "3,3,3",
149
- "GREY": "3,3,3",
150
150
  "AFM_HOT": "34,35,36",
151
151
  "PACKING": "PACKING",
152
152
  "RED_HOT": "21,22,23",
@@ -451,6 +451,38 @@ class PaletteCreator:
451
451
 
452
452
  return equation
453
453
 
454
+ # def computeEquation(self, equation, variable, val):
455
+ # """
456
+ # Computes the result of an equation using the numexpr library.
457
+ #
458
+ # Args:
459
+ # equation (str): The equation to compute.
460
+ # variable (str): The variable name in the equation.
461
+ # val: The value for the variable.
462
+ #
463
+ # Returns:
464
+ # float: The computed result of the equation.
465
+ #
466
+ # # Examples:
467
+ # # >>> palette_creator = PaletteCreator()
468
+ # # >>> result = palette_creator.computeEquation("2*a*(b/c)**2", "a", [1, 2, 2])
469
+ # # >>> print(result)
470
+ # # array([0.88888889, 0.44444444, 4.])
471
+ # """
472
+ # import numexpr as ne
473
+ # var = {'a': np.array([1, 2, 2]), 'b': np.array([2, 1, 3]), 'c': np.array([3])}
474
+ # print('TOO', ne.evaluate('2*a*(b/c)**2', local_dict=var))
475
+ # try:
476
+ # for i in range(10):
477
+ # equation = equation.replace(str(i) + variable, str(i) + "*" + variable)
478
+ # for i in range(10):
479
+ # equation = equation.replace(variable + str(i), variable + "*" + str(i))
480
+ #
481
+ # equation = equation.replace(variable, "(double)" + variable)
482
+ # print(equation)
483
+ # except:
484
+ # traceback.print_exc()
485
+ # return 0
454
486
  def computeEquation(self, equation, variable, val):
455
487
  """
456
488
  Computes the result of an equation using the numexpr library.
@@ -461,28 +493,29 @@ class PaletteCreator:
461
493
  val: The value for the variable.
462
494
 
463
495
  Returns:
464
- float: The computed result of the equation.
465
-
466
- # Examples:
467
- # >>> palette_creator = PaletteCreator()
468
- # >>> result = palette_creator.computeEquation("2*a*(b/c)**2", "a", [1, 2, 2])
469
- # >>> print(result)
470
- # array([0.88888889, 0.44444444, 4.])
496
+ numpy.ndarray: The computed result of the equation.
471
497
  """
472
- import numexpr as ne
473
- var = {'a': np.array([1, 2, 2]), 'b': np.array([2, 1, 3]), 'c': np.array([3])}
474
- print('TOO', ne.evaluate('2*a*(b/c)**2', local_dict=var))
475
498
  try:
476
- for i in range(10):
477
- equation = equation.replace(str(i) + variable, str(i) + "*" + variable)
478
- for i in range(10):
479
- equation = equation.replace(variable + str(i), variable + "*" + str(i))
480
-
481
- equation = equation.replace(variable, "(double)" + variable)
482
- print(equation)
483
- except:
499
+ # Handle the special case where the equation is just a minus sign
500
+ if equation.strip() == '-':
501
+ return -np.array(val)
502
+ if equation.strip() == '+':
503
+ return np.array(val)
504
+ # Prepare the variable dictionary
505
+ var = {variable: np.array(val)}
506
+
507
+ # Print the equation and variables for debugging
508
+ print(f"Evaluating equation: {equation}")
509
+ print(f"Variables: {var}")
510
+ # Evaluate the equation using numexpr
511
+ result = ne.evaluate(equation, local_dict=var)
512
+
513
+ return result
514
+ except Exception as e:
515
+ # Print the traceback and the error message
484
516
  traceback.print_exc()
485
- return 0
517
+ print(f"Error evaluating the equation '{equation}': {e}")
518
+ return np.zeros_like(val) # Return an array of zeros with the same shape as val
486
519
 
487
520
  def create5(self, red, green, blue):
488
521
  """
@@ -773,7 +806,7 @@ class PaletteCreator:
773
806
  final_palette = None
774
807
  try:
775
808
  r = g = b = 3
776
- if "," in palette_name:
809
+ if palette_name and "," in palette_name:
777
810
  formula_size = len(palette_name.split(","))
778
811
  if formula_size == 3:
779
812
  r = int(palette_name.split(",")[0])
@@ -786,15 +819,22 @@ class PaletteCreator:
786
819
  equa2 = new_equa2
787
820
  equa3 = new_equa3
788
821
 
822
+ # print('passing there')
823
+
789
824
  if abs(r) < 37 and abs(g) < 37 and abs(b) < 37:
790
825
  return self.create3(palette_name)
791
826
 
792
827
  if abs(r) >= 37 and abs(g) >= 37 and abs(b) >= 37:
793
828
  palette1 = self.createEmptyPalette()
794
829
  else:
795
- palette1 = self.create(palette_name)
830
+ palette1 = self.create3(palette_name)
796
831
 
832
+ # print('inside equa', equa1, equa2, equa3)
797
833
  palette2 = self.create_from_formula(equa1, equa2, equa3)
834
+
835
+
836
+ # print(palette2.shape)
837
+
798
838
  final_palette = np.zeros((palette1.shape[0], palette1.shape[1]), dtype=np.uint8)
799
839
  l = 0
800
840
  l1 = 0
@@ -812,9 +852,14 @@ class PaletteCreator:
812
852
  green = green2 if abs(g) >= 37 and abs(g) <= 39 else green1
813
853
  blue = blue2 if abs(b) >= 37 and abs(b) <= 39 else blue1
814
854
 
815
- final_palette[l, 0] = red
816
- final_palette[l, 1] = green
817
- final_palette[l, 2] = blue
855
+ # print('final_palette', final_palette.shape)
856
+ # print('red', red)
857
+ # print('green', green)
858
+ # print('blue', blue)
859
+
860
+ final_palette[l, 0] = red[0]
861
+ final_palette[l, 1] = green[1]
862
+ final_palette[l, 2] = blue[2]
818
863
  l += 1
819
864
  except:
820
865
  traceback.print_exc()
@@ -0,0 +1,204 @@
1
+ from batoolset.pyqts.tools import updateLutLabelPreview
2
+ from batoolset.settings.global_settings import set_UI # set the UI to qtpy
3
+ set_UI()
4
+ import sys
5
+ import random
6
+ from qtpy.QtWidgets import (
7
+ QApplication, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit,
8
+ QPushButton, QTextEdit, QGroupBox, QMessageBox, QScrollArea,QSizePolicy,
9
+ )
10
+ from qtpy.QtCore import Qt
11
+ from qtpy.QtGui import QFont
12
+
13
+ from batoolset.luts.lut_minimal_test import PaletteCreator, list_available_luts, apply_lut, lsm_LUT_to_numpy
14
+
15
+
16
+
17
+
18
+ class PaletteFormulaEditor(QWidget):
19
+ def __init__(self, parent=None):
20
+ super().__init__(parent)
21
+ self.palette = None
22
+
23
+ # Initialize the UI components
24
+ self.initUI()
25
+
26
+ def initUI(self):
27
+ layout = QVBoxLayout()
28
+
29
+ # Preview Panel
30
+ self.preview_group = QGroupBox("Preview")
31
+ preview_layout = QVBoxLayout()
32
+ # Align the QLabel to the center
33
+
34
+ self.previewLabel = QLabel()
35
+ # self.previewLabel.setFixedSize(750,16)
36
+ preview_layout.addWidget(self.previewLabel)
37
+ preview_layout.setAlignment(self.previewLabel, Qt.AlignCenter)
38
+ self.preview_group.setLayout(preview_layout)
39
+ layout.addWidget(self.preview_group)
40
+
41
+ # Formula Panel
42
+ self.formula_group = QGroupBox("Formula")
43
+ formula_layout = QVBoxLayout()
44
+
45
+ h_layout1 = QHBoxLayout()
46
+ h_layout2 = QHBoxLayout()
47
+
48
+ # Red Formula
49
+ self.redLabel = QLabel("Red Formula:")
50
+ self.redFormula = QLineEdit("34")
51
+ self.redFormula.textChanged.connect(self.update_palette)
52
+
53
+ # Green Formula
54
+ self.greenLabel = QLabel("Green Formula:")
55
+ self.greenFormula = QLineEdit("35")
56
+ self.greenFormula.textChanged.connect(self.update_palette)
57
+
58
+ # Blue Formula
59
+ self.blueLabel = QLabel("Blue Formula:")
60
+ self.blueFormula = QLineEdit("36")
61
+ self.blueFormula.textChanged.connect(self.update_palette)
62
+
63
+ # Add to layout
64
+ h_layout1.addWidget(self.redLabel)
65
+ h_layout1.addWidget(self.redFormula)
66
+ h_layout1.addWidget(self.greenLabel)
67
+ h_layout1.addWidget(self.greenFormula)
68
+ h_layout1.addWidget(self.blueLabel)
69
+ h_layout1.addWidget(self.blueFormula)
70
+
71
+
72
+ # Equation Text Fields
73
+ self.eqLabel1 = QLabel("Eq. #1:")
74
+ self.eq1 = QLineEdit("x")
75
+ self.eq1.textChanged.connect(self.update_palette)
76
+
77
+ self.eqLabel2 = QLabel("Eq. #2:")
78
+ self.eq2 = QLineEdit("x")
79
+ self.eq2.textChanged.connect(self.update_palette)
80
+
81
+ self.eqLabel3 = QLabel("Eq. #3:")
82
+ self.eq3 = QLineEdit("x")
83
+ self.eq3.textChanged.connect(self.update_palette)
84
+
85
+ # Random Button
86
+ self.randomButton = QPushButton("Random")
87
+ self.randomButton.clicked.connect(self.randomize_formulas)
88
+
89
+ # Update Button
90
+ # self.updateButton = QPushButton("Update")
91
+ # self.updateButton.clicked.connect(self.update_palette)
92
+
93
+ if False: # TODO --> really connect this in the future but ok for now
94
+ h_layout2.addWidget(self.eqLabel1)
95
+ h_layout2.addWidget(self.eq1)
96
+ h_layout2.addWidget(self.eqLabel2)
97
+ h_layout2.addWidget(self.eq2)
98
+ h_layout2.addWidget(self.eqLabel3)
99
+ h_layout2.addWidget(self.eq3)
100
+ h_layout2.addWidget(self.randomButton)
101
+ # h_layout2.addWidget(self.updateButton)
102
+
103
+ # Text Area
104
+ self.textArea = QTextEdit()
105
+ self.textArea.setReadOnly(True)
106
+ self.textArea.setText(
107
+ "0: 0\t\t\t1: 0.5\t\t\t2: 1\n"
108
+ "3: x\t\t\t4: x^2\t\t\t5: x^3\n"
109
+ "6: x^4\t\t\t7: sqrt(x)\t\t8: sqrt(sqrt(x))\n"
110
+ "9: sin(90*x)\t\t10: cos(90*x)\t\t11: |x-0.5|\n"
111
+ "12: (2*x-1)^2\t\t13: sin(180*x)\t\t14: |cos(180*x)|\n"
112
+ "15: sin(360*x)\t\t16: cos(360*x)\t\t17: |sin(360*x)|\n"
113
+ "18: |cos(360*x)|\t\t19: |sin(720*x)|\t\t20: |cos(720*x)|\n"
114
+ "21: 3*x\t\t\t22: 3*x-1\t\t23: 3*x-2\n"
115
+ "24: |3*x-1|\t\t25: |3*x-2|\t\t26: (3*x-1)/2\n"
116
+ "27: (3*x-2)/2\t\t28: |(3*x-1)/2|\t\t29: |(3*x-2)/2|\n"
117
+ "30: x/0.32-25/32\t\t31: 2*x-0.84\t\t32: x\n"
118
+ "33: |2*x - 0.5|\t\t34: 2*x\t\t\t35: 2*x - 0.5\n"
119
+ "36: 2*x - 1\t\t37: eq. #1\t\t38: eq. #2\n"
120
+ "39: eq. #3\n\n"
121
+ "NB: negative numbers --> returns the negative of the generated palette\n"
122
+ "NB2: I used Gnuplot numbering for equations to promote compatibility between the 2 softwares\n"
123
+ "NB3: the idea of using formulas to create LUTs is coming from Gnuplot"
124
+ )
125
+ # Set the font to monospace
126
+ font = QFont("Courier New", 12) # You can adjust the font size as needed
127
+ self.textArea.setFont(font)
128
+
129
+ # Disable scrollbars
130
+ self.textArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
131
+ self.textArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
132
+
133
+ # Resize QTextEdit to fit its content
134
+ self.textArea.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
135
+ self.textArea.setMinimumHeight(360) # Set a minimum height to ensure it's usable
136
+
137
+ formula_layout.addLayout(h_layout1)
138
+ formula_layout.addLayout(h_layout2)
139
+ formula_layout.addWidget(self.textArea)
140
+
141
+ self.formula_group.setLayout(formula_layout)
142
+ layout.addWidget(self.formula_group)
143
+
144
+ self.setLayout(layout)
145
+
146
+ self.update_palette()
147
+
148
+
149
+ def randomize_formulas(self):
150
+ rand = int(self.randomSign(random.uniform(0, 39)))
151
+ self.redFormula.setText(str(rand))
152
+ rand = int(self.randomSign(random.uniform(0, 39)))
153
+ self.greenFormula.setText(str(rand))
154
+ rand = int(self.randomSign(random.uniform(0, 39)))
155
+ self.blueFormula.setText(str(rand))
156
+ self.update_palette()
157
+
158
+ def randomSign(self, nb):
159
+ return nb if random.random() > 0.5 else -nb
160
+
161
+ def update_palette(self):
162
+ if self.check_validity():
163
+ # Here, you would call your function to create and update the palette
164
+ self.palette = self.create_palette(
165
+ self.redFormula.text(),
166
+ self.greenFormula.text(),
167
+ self.blueFormula.text(),
168
+ self.eq1.text(),
169
+ self.eq2.text(),
170
+ self.eq3.text()
171
+ )
172
+ self.show_palette()
173
+ def check_validity(self):
174
+ return all([self.redFormula.text(), self.greenFormula.text(), self.blueFormula.text()])
175
+
176
+ def create_palette(self, red_formula, green_formula, blue_formula, eq1, eq2, eq3):
177
+ # print('red_formula, green_formula, blue_formula, eq1, eq2, eq3', red_formula, green_formula, blue_formula, eq1, eq2, eq3)
178
+ pc = PaletteCreator()
179
+ # lut = pc.create2(None, str(red_formula)+str(eq1), str(green_formula)+str(eq2), str(blue_formula)+str(eq3))
180
+ lut = pc.create2(f'{str(red_formula)},{ str(green_formula)},{str(blue_formula)}', eq1,eq2, eq3)
181
+
182
+ # print('lut', lut)
183
+
184
+ # self.show_palette()
185
+ return lut # Return the LUT for preview
186
+
187
+ def show_palette(self):
188
+ if self.palette is not None:
189
+ # print('show_palette called')
190
+ # Compute the total length based on your button dimensions and spacing
191
+ total_length = 760#(button_width * 16) + (spacing * 15) # Adjust based on columns and spacing
192
+ updateLutLabelPreview(self.palette, self.previewLabel, total_length, height=32)
193
+ else:
194
+ if self.check_validity():
195
+ QMessageBox.warning(self, "No Palette", "No palette to display. Please generate a palette first.")
196
+
197
+
198
+ if __name__ == '__main__':
199
+ app = QApplication(sys.argv)
200
+ jar_folder = "" # Provide the correct path if needed
201
+ ex = PaletteFormulaEditor()
202
+ ex.setWindowTitle('Palette Formula Editor')
203
+ ex.show()
204
+ sys.exit(app.exec_())
@@ -0,0 +1,116 @@
1
+ from batoolset.settings.global_settings import set_UI # set the UI to qtpy
2
+ set_UI()
3
+ import sys
4
+ from qtpy.QtWidgets import QApplication, QWidget, QGridLayout, QPushButton, QColorDialog, QLabel, QVBoxLayout
5
+ from qtpy.QtGui import QColor, QPixmap, QImage
6
+ from qtpy.QtCore import Qt
7
+ from batoolset.pyqts.tools import updateLutLabelPreview
8
+
9
+ class PaletteEditor(QWidget):
10
+ def __init__(self, lut=None, parent=None):
11
+ super().__init__(parent)
12
+
13
+ self.button_width = 40 # Example button width
14
+ self.button_height = 20 # Example button height
15
+ self.spacing = 2 # Example spacing
16
+
17
+ self.rows = 16
18
+ self.columns = 16
19
+ self.buttons = {}
20
+
21
+ self.initUI()
22
+
23
+ if lut:
24
+ self.setLUT(lut)
25
+ else:
26
+ self.setDefaultLUT()
27
+
28
+ # self.updatePreview()
29
+ total_length = (self.button_width * self.columns) + ( self.spacing * (self.columns - 1))
30
+ updateLutLabelPreview(self.getLUT(), self.previewLabel,total_length)
31
+
32
+ def initUI(self):
33
+ mainLayout = QVBoxLayout()
34
+
35
+ gridLayout = QGridLayout()
36
+ gridLayout.setSpacing(2)
37
+
38
+ for row in range(self.rows):
39
+ for col in range(self.columns):
40
+ button = QPushButton()
41
+ button.setFixedSize(self.button_width, self.button_height)
42
+ button.setStyleSheet("background-color: white;")
43
+ button.clicked.connect(lambda _, r=row, c=col: self.openColorDialog(r, c))
44
+
45
+ gridLayout.addWidget(button, row, col)
46
+ self.buttons[(row, col)] = button
47
+
48
+ self.previewLabel = QLabel()
49
+ gridLayout.addWidget(self.previewLabel, self.rows, 0, 1, self.columns)
50
+
51
+ mainLayout.addLayout(gridLayout)
52
+ self.setLayout(mainLayout)
53
+ self.setWindowTitle('Palette Editor (256 entries)')
54
+ self.show()
55
+
56
+ def openColorDialog(self, row, col):
57
+ button = self.buttons[(row, col)]
58
+ current_color = button.palette().color(button.backgroundRole())
59
+
60
+ color = QColorDialog.getColor(current_color, self)
61
+
62
+ if color.isValid():
63
+ button.setStyleSheet(f"background-color: {color.name()};")
64
+ # self.updatePreview()
65
+ total_length = (self.button_width * self.columns) + (self.spacing * (self.columns - 1))
66
+ updateLutLabelPreview(self.getLUT(), self.previewLabel, total_length)
67
+
68
+ def getLUT(self):
69
+ lut = []
70
+ for row in range(self.rows):
71
+ for col in range(self.columns):
72
+ button = self.buttons[(row, col)]
73
+ color = button.palette().color(button.backgroundRole())
74
+ lut.append(color.name())
75
+ return lut
76
+
77
+ def setLUT(self, lut):
78
+ if len(lut) != 256:
79
+ raise ValueError("LUT must contain exactly 256 entries")
80
+
81
+ index = 0
82
+ for row in range(self.rows):
83
+ for col in range(self.columns):
84
+ color = QColor(lut[index])
85
+ if color.isValid():
86
+ self.buttons[(row, col)].setStyleSheet(f"background-color: {color.name()};")
87
+ index += 1
88
+
89
+ def setDefaultLUT(self):
90
+ default_lut = [f"#{i:02x}{i:02x}{i:02x}" for i in range(256)]
91
+ self.setLUT(default_lut)
92
+
93
+ # def updatePreview(self):
94
+ # lut = self.getLUT()
95
+ # image = QImage(256, 16, QImage.Format_RGB32)
96
+ #
97
+ # for i in range(256):
98
+ # color = QColor(lut[i])
99
+ # for j in range(16):
100
+ # image.setPixelColor(i, j, color)
101
+ #
102
+ # pixmap = QPixmap.fromImage(image)
103
+ # total_width = (40 * self.columns) + (2 * (self.columns - 1))
104
+ # scaled_pixmap = pixmap.scaled(total_width, 16, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
105
+ # self.previewLabel.setPixmap(scaled_pixmap)
106
+
107
+
108
+ if __name__ == '__main__':
109
+ # this is the first version of my LUT editor
110
+
111
+ app = QApplication(sys.argv)
112
+
113
+ # Create PaletteEditor with the default grayscale LUT
114
+ ex = PaletteEditor()
115
+
116
+ sys.exit(app.exec_())
@@ -1,13 +1,13 @@
1
1
  from batoolset.settings.global_settings import set_UI # set the UI to qtpy
2
2
  set_UI()
3
- from qtpy.QtGui import QPainter,QTransform,QImage,QPolygonF,QFont, QTextDocument,QColor,QPolygon
3
+ from qtpy.QtGui import QPainter,QTransform,QImage,QPolygonF,QFont, QTextDocument,QColor,QPolygon,QPixmap
4
4
  from qtpy.QtCore import QRectF, QPointF, QSize, QRect, QPoint
5
5
  from qtpy.QtCore import Qt, QObject, QEvent
6
6
  from qtpy.QtWidgets import QHBoxLayout, QSlider,QLabel,QComboBox,QSpinBox,QWidget,QScrollArea,QDoubleSpinBox
7
7
  import math
8
+ import numpy as np
8
9
  import sys
9
10
 
10
-
11
11
  # class WheelFilter(QObject):
12
12
  # def eventFilter(self, obj, event):
13
13
  # if event.type() == QEvent.Wheel:
@@ -44,7 +44,43 @@ import sys
44
44
  # blocker = WheelBlocker(app)
45
45
  # app.installEventFilter(blocker)
46
46
 
47
+ def updateLutLabelPreview(lut, previewLabel, length, orientation='horizontal', height=16):
48
+ """
49
+ Updates the preview label with an image representing the LUT.
50
+
51
+ :param lut: List of color values in the LUT.
52
+ :param previewLabel: The QLabel where the preview image will be displayed.
53
+ :param length: The total length of the preview, including buttons and spacing.
54
+ :param orientation: The orientation of the LUT ('horizontal' or 'vertical').
55
+ """
56
+ image = QImage(256, height, QImage.Format_RGB32)
57
+
58
+ for i in range(256):
59
+ if isinstance(lut[i], str):
60
+ # If lut[i] is a string, convert it to QColor
61
+ color = QColor(lut[i])
62
+ elif isinstance(lut[i], (list, np.ndarray)) and len(lut[i]) == 3:
63
+ # If lut[i] is an RGB array, convert it to QColor
64
+ color = QColor(int(lut[i][0]), int(lut[i][1]), int(lut[i][2]))
65
+ else:
66
+ raise ValueError("LUT entry must be a color string or an RGB array")
67
+
68
+ for j in range(height):
69
+ image.setPixelColor(i, j, color)
70
+
71
+ pixmap = QPixmap.fromImage(image)
72
+ scaled_pixmap = pixmap.scaled(length, height, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
73
+
74
+ if orientation != 'horizontal':
75
+ # Rotate the scaled pixmap 90 degrees clockwise for vertical orientation
76
+ transform = QTransform().rotate(90)
77
+ scaled_pixmap = scaled_pixmap.transformed(transform)
78
+
79
+ previewLabel.setPixmap(scaled_pixmap)
80
+
81
+
47
82
  def getCtrlModifierAsString():
83
+ import sys
48
84
  if sys.platform == "darwin":
49
85
  return "Meta" # Command key on macOS
50
86
  # else:
@@ -1,6 +1,6 @@
1
1
  __MAJOR__ = 0
2
2
  __MINOR__ = 1
3
- __MICRO__ = 8
3
+ __MICRO__ = 9
4
4
  __RELEASE__ = '' # a #b # https://www.python.org/dev/peps/pep-0440/#public-version-identifiers --> alpha beta, ...
5
5
  __VERSION__ = ''.join([str(__MAJOR__), '.', str(__MINOR__), '.', str(__MICRO__)])
6
6
  __DESCRIPTION__ = """An aggregate of functions I find useful"""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: batoolset
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: An aggregate of functions I find useful
5
5
  Home-page: https://github.com/baigouy/batoolset
6
6
  Author: Benoit Aigouy
@@ -86,6 +86,8 @@ batoolset/lists/__init__.py
86
86
  batoolset/lists/tools.py
87
87
  batoolset/luts/__init__.py
88
88
  batoolset/luts/lut_minimal_test.py
89
+ batoolset/luts/lutcreatorfromformula.py
90
+ batoolset/luts/luteditor.py
89
91
  batoolset/matplolibs/__init__.py
90
92
  batoolset/matplolibs/tools.py
91
93
  batoolset/nps/__init__.py
File without changes
File without changes