only display middle slice for 3D images
Browse files
app.py
CHANGED
|
@@ -155,6 +155,11 @@ def apply_windowing(image: np.ndarray, subset: str) -> np.ndarray:
|
|
| 155 |
def to_display_image(image: np.ndarray) -> np.ndarray:
|
| 156 |
"""Normalise image for display purposes (uint8, 3-channel)."""
|
| 157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
arr = np.array(image, copy=True)
|
| 159 |
if not np.isfinite(arr).all():
|
| 160 |
arr = np.nan_to_num(arr, nan=0.0)
|
|
|
|
| 155 |
def to_display_image(image: np.ndarray) -> np.ndarray:
|
| 156 |
"""Normalise image for display purposes (uint8, 3-channel)."""
|
| 157 |
|
| 158 |
+
# if image is 3D, keep the middle slice
|
| 159 |
+
if image.ndim == 3:
|
| 160 |
+
gr.Info(f"Image is 3D, we display only the middle slice")
|
| 161 |
+
image = image[:, :, image.shape[2] // 2]
|
| 162 |
+
|
| 163 |
arr = np.array(image, copy=True)
|
| 164 |
if not np.isfinite(arr).all():
|
| 165 |
arr = np.nan_to_num(arr, nan=0.0)
|