vincentgao95 commited on
Commit
f34f536
·
verified ·
1 Parent(s): c2f693f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -32,22 +32,25 @@ def visualize_slices(file_obj, slice_index):
32
  # Plot the slices
33
  fig, axes = plt.subplots(1, 3, figsize=(15, 5))
34
 
35
- axes[0].imshow(slice_axial, cmap='gray')
 
36
  axes[0].set_title("Axial View")
37
  axes[0].axis('off')
38
 
39
- axes[1].imshow(slice_coronal, cmap='gray')
 
40
  axes[1].set_title("Coronal View")
41
  axes[1].axis('off')
42
 
43
- axes[2].imshow(slice_sagittal, cmap='gray')
 
44
  axes[2].set_title("Sagittal View")
45
  axes[2].axis('off')
46
 
47
  # Convert matplotlib figure to PIL Image
48
  buf = io.BytesIO()
49
  plt.tight_layout()
50
- fig.savefig(buf, format='png')
51
  plt.close(fig)
52
  buf.seek(0)
53
  pil_img = Image.open(buf)
 
32
  # Plot the slices
33
  fig, axes = plt.subplots(1, 3, figsize=(15, 5))
34
 
35
+ # Axial view
36
+ axes[0].imshow(slice_axial, cmap='gray', aspect='auto')
37
  axes[0].set_title("Axial View")
38
  axes[0].axis('off')
39
 
40
+ # Coronal view
41
+ axes[1].imshow(slice_coronal, cmap='gray', aspect='auto')
42
  axes[1].set_title("Coronal View")
43
  axes[1].axis('off')
44
 
45
+ # Sagittal view
46
+ axes[2].imshow(slice_sagittal.T, cmap='gray', aspect='auto')
47
  axes[2].set_title("Sagittal View")
48
  axes[2].axis('off')
49
 
50
  # Convert matplotlib figure to PIL Image
51
  buf = io.BytesIO()
52
  plt.tight_layout()
53
+ fig.savefig(buf, format='png', dpi=100, bbox_inches='tight', pad_inches=0.1)
54
  plt.close(fig)
55
  buf.seek(0)
56
  pil_img = Image.open(buf)