cdancette commited on
Commit
467b7ba
·
1 Parent(s): d76fff9

only display middle slice for 3D images

Browse files
Files changed (1) hide show
  1. app.py +5 -0
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)