img-phy-sim 0.8__tar.gz → 1.0__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.
- {img_phy_sim-0.8 → img_phy_sim-1.0}/PKG-INFO +97 -3
- {img_phy_sim-0.8 → img_phy_sim-1.0}/README.md +94 -1
- {img_phy_sim-0.8 → img_phy_sim-1.0}/img_phy_sim/data.py +4 -4
- {img_phy_sim-0.8 → img_phy_sim-1.0}/img_phy_sim/img.py +148 -89
- {img_phy_sim-0.8 → img_phy_sim-1.0}/img_phy_sim/ism.py +121 -90
- {img_phy_sim-0.8 → img_phy_sim-1.0}/img_phy_sim/math.py +33 -10
- {img_phy_sim-0.8 → img_phy_sim-1.0}/img_phy_sim/ray_tracing.py +967 -191
- {img_phy_sim-0.8 → img_phy_sim-1.0}/img_phy_sim.egg-info/PKG-INFO +97 -3
- {img_phy_sim-0.8 → img_phy_sim-1.0}/img_phy_sim.egg-info/requires.txt +1 -0
- {img_phy_sim-0.8 → img_phy_sim-1.0}/setup.py +4 -4
- {img_phy_sim-0.8 → img_phy_sim-1.0}/img_phy_sim/__init__.py +0 -0
- {img_phy_sim-0.8 → img_phy_sim-1.0}/img_phy_sim/eval.py +0 -0
- {img_phy_sim-0.8 → img_phy_sim-1.0}/img_phy_sim/ism_slow.py +0 -0
- {img_phy_sim-0.8 → img_phy_sim-1.0}/img_phy_sim.egg-info/SOURCES.txt +0 -0
- {img_phy_sim-0.8 → img_phy_sim-1.0}/img_phy_sim.egg-info/dependency_links.txt +0 -0
- {img_phy_sim-0.8 → img_phy_sim-1.0}/img_phy_sim.egg-info/top_level.txt +0 -0
- {img_phy_sim-0.8 → img_phy_sim-1.0}/pyproject.toml +0 -0
- {img_phy_sim-0.8 → img_phy_sim-1.0}/setup.cfg +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: img-phy-sim
|
|
3
|
-
Version: 0
|
|
3
|
+
Version: 1.0
|
|
4
4
|
Summary: Physical Simulations on Images.
|
|
5
5
|
Home-page: https://github.com/M-106/Image-Physics-Simulation
|
|
6
|
-
Download-URL: https://github.com/M-106/Image-Physics-Simulation/archive/
|
|
6
|
+
Download-URL: https://github.com/M-106/Image-Physics-Simulation/archive/v_05.tar.gz
|
|
7
7
|
Author: Tobia Ippolito
|
|
8
8
|
Project-URL: Documentation, https://M-106.github.io/Image-Physics-Simulation/img_phy_sim
|
|
9
9
|
Project-URL: Source, https://github.com/M-106/Image-Physics-Simulation
|
|
@@ -23,6 +23,7 @@ Requires-Dist: matplotlib
|
|
|
23
23
|
Requires-Dist: scikit-image
|
|
24
24
|
Requires-Dist: joblib
|
|
25
25
|
Requires-Dist: shapely
|
|
26
|
+
Requires-Dist: numba
|
|
26
27
|
Provides-Extra: full
|
|
27
28
|
Requires-Dist: torch; extra == "full"
|
|
28
29
|
Requires-Dist: torchvision; extra == "full"
|
|
@@ -657,7 +658,100 @@ Short form:
|
|
|
657
658
|
|
|
658
659
|
How to use which of them in `img-phy-sim`:
|
|
659
660
|
|
|
660
|
-
|
|
661
|
+
Classical Ray-Tracing:
|
|
662
|
+
```python
|
|
663
|
+
# calc rays
|
|
664
|
+
rays = ips.ray_tracing.trace_beams(rel_position=[0.5, 0.5],
|
|
665
|
+
img_src=input_src,
|
|
666
|
+
directions_in_degree=ips.math.get_linear_degree_range(start=0, stop=360, step_size=5),
|
|
667
|
+
wall_values=None,
|
|
668
|
+
wall_thickness=1,
|
|
669
|
+
img_border_also_collide=False,
|
|
670
|
+
reflexion_order=3,
|
|
671
|
+
should_scale_rays=True,
|
|
672
|
+
should_scale_img=False)
|
|
673
|
+
|
|
674
|
+
# show rays on input
|
|
675
|
+
ray_img = ips.ray_tracing.draw_rays(rays, detail_draw=False,
|
|
676
|
+
output_format="single_image",
|
|
677
|
+
img_background=input_, ray_value=2, ray_thickness=1,
|
|
678
|
+
img_shape=(256, 256), dtype=float, standard_value=0,
|
|
679
|
+
should_scale_rays_to_image=True, original_max_width=None, original_max_height=None,
|
|
680
|
+
show_only_reflections=True)
|
|
681
|
+
ips.img.imshow(ray_img, size=4)
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
ISM:
|
|
685
|
+
```python
|
|
686
|
+
reflection_map = ips.ism.compute_reflection_map(
|
|
687
|
+
source_rel=(0.5, 0.5),
|
|
688
|
+
img=ips.img.open(input_src),
|
|
689
|
+
wall_values=[0],
|
|
690
|
+
wall_thickness=1,
|
|
691
|
+
max_order=1,
|
|
692
|
+
step_px=1,
|
|
693
|
+
parallelization=-1
|
|
694
|
+
)
|
|
695
|
+
|
|
696
|
+
ips.img.imshow(ips.ism.reflection_map_to_img(reflection_map), size=5)
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
<br><br>
|
|
700
|
+
|
|
701
|
+
Both formats are also available in a **iterative format**.
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
Classical Ray-Tracing:
|
|
705
|
+
```python
|
|
706
|
+
rays_ = ips.ray_tracing.trace_beams(rel_position=[0.5, 0.5],
|
|
707
|
+
img_src=img_src,
|
|
708
|
+
directions_in_degree=[22, 56, 90, 146, 234, 285, 320],
|
|
709
|
+
wall_values=0.0,
|
|
710
|
+
wall_thickness=0,
|
|
711
|
+
img_border_also_collide=False,
|
|
712
|
+
reflexion_order=2,
|
|
713
|
+
should_scale_rays=False,
|
|
714
|
+
should_scale_img=True,
|
|
715
|
+
iterative_tracking=True, # IMPORTANT
|
|
716
|
+
iterative_steps=None # IMPORTANT
|
|
717
|
+
)
|
|
718
|
+
print("\nAccessing works the same, example Ray:", rays_[0][0][:min(len(rays_[0][0])-1, 3)])
|
|
719
|
+
|
|
720
|
+
ray_imgs = ips.ray_tracing.draw_rays(rays_, detail_draw=False,
|
|
721
|
+
output_format="single_image",
|
|
722
|
+
img_background=img, ray_value=2, ray_thickness=1,
|
|
723
|
+
img_shape=(256, 256), dtype=float, standard_value=0,
|
|
724
|
+
should_scale_rays_to_image=False, original_max_width=None, original_max_height=None)
|
|
661
725
|
|
|
726
|
+
ips.img.advanced_imshow(ray_imgs[:10], title=None, image_width=4, axis=False,
|
|
727
|
+
color_space="gray", cmap=None, cols=5, save_to=None,
|
|
728
|
+
hspace=0.2, wspace=0.2,
|
|
729
|
+
use_original_style=False, invert=False)
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
ISM:
|
|
733
|
+
```python
|
|
734
|
+
reflection_map_per_time = ips.ism.compute_reflection_map(
|
|
735
|
+
source_rel=(0.5, 0.5),
|
|
736
|
+
img=ips.img.open(input_src),
|
|
737
|
+
wall_values=[0],
|
|
738
|
+
wall_thickness=1,
|
|
739
|
+
max_order=1,
|
|
740
|
+
step_px=1,
|
|
741
|
+
iterative_tracking=True,
|
|
742
|
+
iterative_steps=6, # IMPORTANT
|
|
743
|
+
parallelization=-1 # IMPORTANT
|
|
744
|
+
)
|
|
745
|
+
|
|
746
|
+
ips.img.imshow(ips.ism.reflection_map_to_img(reflection_map_per_time[0]), size=5)
|
|
747
|
+
|
|
748
|
+
len_ = len(reflection_map_per_time)
|
|
749
|
+
ips.img.advanced_imshow([reflection_map_per_time[0], reflection_map_per_time[1], reflection_map_per_time[2],
|
|
750
|
+
reflection_map_per_time[3], reflection_map_per_time[4], reflection_map_per_time[5]],
|
|
751
|
+
title=None, image_width=4, axis=False,
|
|
752
|
+
color_space="gray", cmap=None, cols=3, save_to=None,
|
|
753
|
+
hspace=0.2, wspace=0.2,
|
|
754
|
+
use_original_style=False, invert=False)
|
|
755
|
+
```
|
|
662
756
|
|
|
663
757
|
|
|
@@ -615,7 +615,100 @@ Short form:
|
|
|
615
615
|
|
|
616
616
|
How to use which of them in `img-phy-sim`:
|
|
617
617
|
|
|
618
|
-
|
|
618
|
+
Classical Ray-Tracing:
|
|
619
|
+
```python
|
|
620
|
+
# calc rays
|
|
621
|
+
rays = ips.ray_tracing.trace_beams(rel_position=[0.5, 0.5],
|
|
622
|
+
img_src=input_src,
|
|
623
|
+
directions_in_degree=ips.math.get_linear_degree_range(start=0, stop=360, step_size=5),
|
|
624
|
+
wall_values=None,
|
|
625
|
+
wall_thickness=1,
|
|
626
|
+
img_border_also_collide=False,
|
|
627
|
+
reflexion_order=3,
|
|
628
|
+
should_scale_rays=True,
|
|
629
|
+
should_scale_img=False)
|
|
630
|
+
|
|
631
|
+
# show rays on input
|
|
632
|
+
ray_img = ips.ray_tracing.draw_rays(rays, detail_draw=False,
|
|
633
|
+
output_format="single_image",
|
|
634
|
+
img_background=input_, ray_value=2, ray_thickness=1,
|
|
635
|
+
img_shape=(256, 256), dtype=float, standard_value=0,
|
|
636
|
+
should_scale_rays_to_image=True, original_max_width=None, original_max_height=None,
|
|
637
|
+
show_only_reflections=True)
|
|
638
|
+
ips.img.imshow(ray_img, size=4)
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
ISM:
|
|
642
|
+
```python
|
|
643
|
+
reflection_map = ips.ism.compute_reflection_map(
|
|
644
|
+
source_rel=(0.5, 0.5),
|
|
645
|
+
img=ips.img.open(input_src),
|
|
646
|
+
wall_values=[0],
|
|
647
|
+
wall_thickness=1,
|
|
648
|
+
max_order=1,
|
|
649
|
+
step_px=1,
|
|
650
|
+
parallelization=-1
|
|
651
|
+
)
|
|
652
|
+
|
|
653
|
+
ips.img.imshow(ips.ism.reflection_map_to_img(reflection_map), size=5)
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
<br><br>
|
|
657
|
+
|
|
658
|
+
Both formats are also available in a **iterative format**.
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
Classical Ray-Tracing:
|
|
662
|
+
```python
|
|
663
|
+
rays_ = ips.ray_tracing.trace_beams(rel_position=[0.5, 0.5],
|
|
664
|
+
img_src=img_src,
|
|
665
|
+
directions_in_degree=[22, 56, 90, 146, 234, 285, 320],
|
|
666
|
+
wall_values=0.0,
|
|
667
|
+
wall_thickness=0,
|
|
668
|
+
img_border_also_collide=False,
|
|
669
|
+
reflexion_order=2,
|
|
670
|
+
should_scale_rays=False,
|
|
671
|
+
should_scale_img=True,
|
|
672
|
+
iterative_tracking=True, # IMPORTANT
|
|
673
|
+
iterative_steps=None # IMPORTANT
|
|
674
|
+
)
|
|
675
|
+
print("\nAccessing works the same, example Ray:", rays_[0][0][:min(len(rays_[0][0])-1, 3)])
|
|
676
|
+
|
|
677
|
+
ray_imgs = ips.ray_tracing.draw_rays(rays_, detail_draw=False,
|
|
678
|
+
output_format="single_image",
|
|
679
|
+
img_background=img, ray_value=2, ray_thickness=1,
|
|
680
|
+
img_shape=(256, 256), dtype=float, standard_value=0,
|
|
681
|
+
should_scale_rays_to_image=False, original_max_width=None, original_max_height=None)
|
|
619
682
|
|
|
683
|
+
ips.img.advanced_imshow(ray_imgs[:10], title=None, image_width=4, axis=False,
|
|
684
|
+
color_space="gray", cmap=None, cols=5, save_to=None,
|
|
685
|
+
hspace=0.2, wspace=0.2,
|
|
686
|
+
use_original_style=False, invert=False)
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
ISM:
|
|
690
|
+
```python
|
|
691
|
+
reflection_map_per_time = ips.ism.compute_reflection_map(
|
|
692
|
+
source_rel=(0.5, 0.5),
|
|
693
|
+
img=ips.img.open(input_src),
|
|
694
|
+
wall_values=[0],
|
|
695
|
+
wall_thickness=1,
|
|
696
|
+
max_order=1,
|
|
697
|
+
step_px=1,
|
|
698
|
+
iterative_tracking=True,
|
|
699
|
+
iterative_steps=6, # IMPORTANT
|
|
700
|
+
parallelization=-1 # IMPORTANT
|
|
701
|
+
)
|
|
702
|
+
|
|
703
|
+
ips.img.imshow(ips.ism.reflection_map_to_img(reflection_map_per_time[0]), size=5)
|
|
704
|
+
|
|
705
|
+
len_ = len(reflection_map_per_time)
|
|
706
|
+
ips.img.advanced_imshow([reflection_map_per_time[0], reflection_map_per_time[1], reflection_map_per_time[2],
|
|
707
|
+
reflection_map_per_time[3], reflection_map_per_time[4], reflection_map_per_time[5]],
|
|
708
|
+
title=None, image_width=4, axis=False,
|
|
709
|
+
color_space="gray", cmap=None, cols=3, save_to=None,
|
|
710
|
+
hspace=0.2, wspace=0.2,
|
|
711
|
+
use_original_style=False, invert=False)
|
|
712
|
+
```
|
|
620
713
|
|
|
621
714
|
|
|
@@ -167,13 +167,13 @@ if DATA_DEPENDENCIES_AVAILABLE:
|
|
|
167
167
|
Loads PhysGen Dataset.
|
|
168
168
|
|
|
169
169
|
Parameters:
|
|
170
|
-
- variation : str
|
|
170
|
+
- variation : str <br>
|
|
171
171
|
Chooses the used dataset variant: sound_baseline, sound_reflection, sound_diffraction, sound_combined.
|
|
172
|
-
- mode : str
|
|
172
|
+
- mode : str <br>
|
|
173
173
|
Can be "train", "test", "eval".
|
|
174
|
-
- input_type : str
|
|
174
|
+
- input_type : str <br>
|
|
175
175
|
Defines the used Input -> "osm", "base_simulation"
|
|
176
|
-
- output_type : str
|
|
176
|
+
- output_type : str <br>
|
|
177
177
|
Defines the Output -> "standard", "complex_only"
|
|
178
178
|
"""
|
|
179
179
|
self.device = 'cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu'
|
|
@@ -79,11 +79,13 @@ def get_bit_depth(img):
|
|
|
79
79
|
Retrieve the bit depth of an image based on its NumPy data type.
|
|
80
80
|
|
|
81
81
|
Parameters:
|
|
82
|
-
img (numpy.ndarray):
|
|
82
|
+
img (numpy.ndarray): <br>
|
|
83
|
+
Input image array.
|
|
83
84
|
|
|
84
|
-
Returns:
|
|
85
|
-
int or str
|
|
86
|
-
|
|
85
|
+
Returns: <br>
|
|
86
|
+
int or str:<br>
|
|
87
|
+
Bit depth of the image (8, 16, 32, or 64).<br>
|
|
88
|
+
Returns "unknown" if the data type is not recognized.
|
|
87
89
|
|
|
88
90
|
Notes:
|
|
89
91
|
The mapping is defined for common image dtypes:
|
|
@@ -108,10 +110,10 @@ def get_width_height(img, channels_before=0):
|
|
|
108
110
|
Extract the width and height of an image, optionally offset by leading channels.
|
|
109
111
|
|
|
110
112
|
Parameters:
|
|
111
|
-
img (numpy.ndarray):
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
- img (numpy.ndarray): <br>
|
|
114
|
+
Input image array.
|
|
115
|
+
- channels_before (int, optional): <br>
|
|
116
|
+
Offset in the shape dimension if channels precede height and width (default: 0).
|
|
115
117
|
|
|
116
118
|
Returns:
|
|
117
119
|
tuple: (width, height) of the image.
|
|
@@ -131,15 +133,16 @@ def open(src, should_scale=False, auto_scale_method=True, should_print=True, unc
|
|
|
131
133
|
Load a grayscale image from a file path.
|
|
132
134
|
|
|
133
135
|
Parameters:
|
|
134
|
-
src (str): Path to the image file.
|
|
135
|
-
should_scale (bool, optional)
|
|
136
|
-
|
|
137
|
-
auto_scale_method (bool, optionl):
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
- src (str): Path to the image file.
|
|
137
|
+
- should_scale (bool, optional):<br>
|
|
138
|
+
If True, scale pixel values to [0, 1] according to bit depth (default: False).
|
|
139
|
+
- auto_scale_method (bool, optionl): <br>
|
|
140
|
+
If True, the scaling will auto decide to up or down scale
|
|
141
|
+
if should_sclae is also True else always down scale (default: True).
|
|
142
|
+
- should_print (bool, optional): <br>
|
|
143
|
+
If True, print image info to console (default: True).
|
|
144
|
+
|
|
145
|
+
Returns: <br>
|
|
143
146
|
numpy.ndarray: Loaded grayscale image.
|
|
144
147
|
|
|
145
148
|
Example:
|
|
@@ -176,12 +179,14 @@ def save(img, src, should_scale=False, auto_scale_method=True):
|
|
|
176
179
|
Save an image to disk.
|
|
177
180
|
|
|
178
181
|
Parameters:
|
|
179
|
-
img (numpy.ndarray): Image to save.
|
|
180
|
-
src (str):
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
- img (numpy.ndarray): Image to save.
|
|
183
|
+
- src (str): <br>
|
|
184
|
+
Destination file path.
|
|
185
|
+
- should_scale (bool, optional): <br>
|
|
186
|
+
If True, scale pixel values to [0, 1] before saving (default: False).
|
|
187
|
+
- auto_scale_method (bool, optionl): <br>
|
|
188
|
+
If True, the scaling will auto decide to up or down scale
|
|
189
|
+
if should_sclae is also True else always down scale (default: True).
|
|
185
190
|
|
|
186
191
|
Notes:
|
|
187
192
|
- The function uses OpenCV's `cv2.imwrite` for saving.
|
|
@@ -207,11 +212,14 @@ def imshow(img, size=8, axis_off=True, cmap="gray"):
|
|
|
207
212
|
Display an image using Matplotlib.
|
|
208
213
|
|
|
209
214
|
Parameters:
|
|
210
|
-
img (numpy.ndarray):
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
+
- img (numpy.ndarray): <br>
|
|
216
|
+
Image to display.
|
|
217
|
+
- size (int, optional): <br>
|
|
218
|
+
Display size in inches (default: 8).
|
|
219
|
+
- axis_off (bool, optional): <br>
|
|
220
|
+
If True, hides the axes (default: True).
|
|
221
|
+
- cmap (str, optional):<br>
|
|
222
|
+
Colormap name. Use 'random' for a random Matplotlib colormap (default: 'gray').
|
|
215
223
|
|
|
216
224
|
Behavior:
|
|
217
225
|
- If `img` has 3 channels, it is converted from BGR to RGB.
|
|
@@ -267,24 +275,39 @@ def show_samples(input_samples, pred_samples, real_samples, model_name="Model",
|
|
|
267
275
|
It arranges them in a grid and can optionally normalize, invert, or save the output.
|
|
268
276
|
|
|
269
277
|
Parameters:
|
|
270
|
-
input_samples (list[str] or list[np.ndarray]):
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
278
|
+
- input_samples (list[str] or list[np.ndarray]): <br>
|
|
279
|
+
Input sample images.
|
|
280
|
+
- pred_samples (list[str] or list[np.ndarray]): <br>
|
|
281
|
+
Model prediction images.
|
|
282
|
+
- real_samples (list[str] or list[np.ndarray]): <br>
|
|
283
|
+
Ground truth images.
|
|
284
|
+
- model_name (str, optional): <br>
|
|
285
|
+
Name of the model to display in titles (default: "Model").
|
|
286
|
+
- n_samples (int, optional): <br>
|
|
287
|
+
Number of sample groups to display (default: 3).
|
|
288
|
+
- n_cols (int, optional): <br>
|
|
289
|
+
Number of columns per sample group (default: 4).<br>
|
|
290
|
+
Typically: Input | Prediction | Ground Truth | Difference.
|
|
291
|
+
- image_width (int, optional): <br>
|
|
292
|
+
Width of one image in inches (default: 4).
|
|
293
|
+
- cmap (str, optional): <br>
|
|
294
|
+
Colormap for displaying grayscale images (default: "gray").
|
|
295
|
+
- normalize (bool, optional): <br>
|
|
296
|
+
Whether to normalize pixel values to [0, 1] (default: True).
|
|
297
|
+
- invert (bool, optional): <br>
|
|
298
|
+
Whether to invert pixel values (255 - img) (default: False).
|
|
299
|
+
- axis (bool, optional):<br>
|
|
300
|
+
Whether to show image axes (default: False).
|
|
301
|
+
- save_to (str, optional): <br>
|
|
302
|
+
Path to save the figure (default: None).
|
|
303
|
+
- hspace (float, optional): <br>
|
|
304
|
+
Vertical spacing between subplots (default: 0.3).
|
|
305
|
+
- wspace (float, optional): <br>
|
|
306
|
+
Horizontal spacing between subplots (default: 0.2).
|
|
307
|
+
- use_original_style (bool, optional): <br>
|
|
308
|
+
If True, preserves the current matplotlib style (default: False).
|
|
309
|
+
|
|
310
|
+
Returns:<br>
|
|
288
311
|
None
|
|
289
312
|
|
|
290
313
|
Example:
|
|
@@ -364,22 +387,34 @@ def advanced_imshow(img, title=None, image_width=10, axis=False,
|
|
|
364
387
|
input tensors, batch display, color inversion, and saving to disk.
|
|
365
388
|
|
|
366
389
|
Parameters:
|
|
367
|
-
img (np.ndarray):
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
390
|
+
- img (np.ndarray): <br>
|
|
391
|
+
Input image or batch of images.<br>
|
|
392
|
+
Accepted shapes:<br>
|
|
393
|
+
[H, W], [H, W, C], [N, H, W], or [N, H, W, C].
|
|
394
|
+
- title (str or list[str], optional): <br>
|
|
395
|
+
Overall or per-image titles.
|
|
396
|
+
- image_width (int, optional): <br>
|
|
397
|
+
Width of each image in inches (default: 10).
|
|
398
|
+
- axis (bool, optional): <br>
|
|
399
|
+
Whether to show axes (default: False).
|
|
400
|
+
- color_space (str, optional): <br>
|
|
401
|
+
Color space of the image: "RGB", "BGR", "gray", or "HSV" (default: "RGB").
|
|
402
|
+
- cmap (str, optional): <br>
|
|
403
|
+
Matplotlib colormap for grayscale images (default: None).
|
|
404
|
+
- cols (int, optional): <br>
|
|
405
|
+
Number of columns in the subplot grid (default: 1).
|
|
406
|
+
- save_to (str, optional): <br>
|
|
407
|
+
File path to save the figure (default: None).
|
|
408
|
+
- hspace (float, optional): <br>
|
|
409
|
+
Vertical spacing between subplots (default: 0.2).
|
|
410
|
+
- wspace (float, optional): <br>
|
|
411
|
+
Horizontal spacing between subplots (default: 0.2).
|
|
412
|
+
- use_original_style (bool, optional): <br>
|
|
413
|
+
Keep current Matplotlib style if True (default: False).
|
|
414
|
+
- invert (bool, optional): <br>
|
|
415
|
+
Invert color values (default: False).
|
|
416
|
+
|
|
417
|
+
Returns:<br>
|
|
383
418
|
None
|
|
384
419
|
|
|
385
420
|
Example:
|
|
@@ -468,19 +503,31 @@ def show_images(image_paths: list, title=None, image_width=5, axis=False,
|
|
|
468
503
|
Load and display multiple images from disk using `advanced_imshow`.
|
|
469
504
|
|
|
470
505
|
Parameters:
|
|
471
|
-
image_paths (list[str]):
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
506
|
+
- image_paths (list[str]): <br>
|
|
507
|
+
List of file paths to load.
|
|
508
|
+
- title (str or list[str], optional): <br>
|
|
509
|
+
Plot title(s).
|
|
510
|
+
- image_width (int, optional): <br>
|
|
511
|
+
Width of each image (default: 5).
|
|
512
|
+
- axis (bool, optional): <br>
|
|
513
|
+
Whether to display axes (default: False).
|
|
514
|
+
- color_space (str, optional): <br>
|
|
515
|
+
Color space to convert images to.<br>
|
|
516
|
+
One of: "gray", "rgb", "hsv", "bgr" (default: "gray").
|
|
517
|
+
- cmap (str, optional): <br>
|
|
518
|
+
Colormap for grayscale images (default: None).
|
|
519
|
+
- cols (int, optional): <br>
|
|
520
|
+
Number of columns in the grid (default: 2).
|
|
521
|
+
- save_to (str, optional): <br>
|
|
522
|
+
Path to save the figure (default: None).
|
|
523
|
+
- hspace (float, optional): <br>
|
|
524
|
+
Vertical spacing between subplots (default: 0.01).
|
|
525
|
+
- wspace (float, optional): <br>
|
|
526
|
+
Horizontal spacing between subplots (default: 0.01).
|
|
527
|
+
- use_original_style (bool, optional): <br>
|
|
528
|
+
Keep current Matplotlib style (default: False).
|
|
529
|
+
- invert (bool, optional): <br>
|
|
530
|
+
Whether to invert images (default: False).
|
|
484
531
|
|
|
485
532
|
Returns:
|
|
486
533
|
np.ndarray: Loaded images stacked as an array.
|
|
@@ -517,14 +564,20 @@ def plot_image_with_values(img, block_size=8, cmap='gray', title=None,
|
|
|
517
564
|
values are displayed as text annotations directly on the image.
|
|
518
565
|
|
|
519
566
|
Parameters:
|
|
520
|
-
img (np.ndarray):
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
567
|
+
- img (np.ndarray): <br>
|
|
568
|
+
2D grayscale image (H, W) or 3D single-channel image (H, W, 1).
|
|
569
|
+
- block_size (int or tuple, optional): <br>
|
|
570
|
+
Size of each block (default: 8).
|
|
571
|
+
- cmap (str, optional): <br>
|
|
572
|
+
Matplotlib colormap (default: "gray").
|
|
573
|
+
- title (str, optional): <br>
|
|
574
|
+
Plot title (default: None).
|
|
575
|
+
- font_size (int, optional): <br>
|
|
576
|
+
Font size of value annotations (default: 6).
|
|
577
|
+
- save_to (str, optional): <br>
|
|
578
|
+
Path to save the figure (default: None).
|
|
579
|
+
|
|
580
|
+
Returns:<br>
|
|
528
581
|
None
|
|
529
582
|
|
|
530
583
|
Example:
|
|
@@ -596,14 +649,20 @@ def show_image_with_line_and_profile(imgs, axis='row', index=None, titles=None,
|
|
|
596
649
|
and plot the corresponding pixel intensity profile below or beside each image.
|
|
597
650
|
|
|
598
651
|
Parameters:
|
|
599
|
-
imgs (list[np.ndarray])
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
652
|
+
- imgs (list[np.ndarray]):<br>
|
|
653
|
+
List of grayscale images to analyze.
|
|
654
|
+
- axis (str, optional):<br>
|
|
655
|
+
Direction of the line ("row" or "column") (default: "row").
|
|
656
|
+
- index (int, optional): <br>
|
|
657
|
+
Index of the selected line. If None, the central line is used (default: None).
|
|
658
|
+
- titles (list[str], optional): <br>
|
|
659
|
+
Titles for each image (default: ["Image 1", "Image 2", ...]).
|
|
660
|
+
- figsize (tuple, optional): <br>
|
|
661
|
+
Figure size per image pair (default: (10, 4)).
|
|
604
662
|
|
|
605
663
|
Returns:
|
|
606
|
-
list[np.ndarray]:
|
|
664
|
+
- list[np.ndarray]: <br>
|
|
665
|
+
List of pixel intensity profiles corresponding to the selected line in each image.
|
|
607
666
|
|
|
608
667
|
Example:
|
|
609
668
|
>>> show_image_with_line_and_profile(
|