BaşlayınÜcretsiz Başlayın

Plot other views

Any two dimensions of an array can form an image, and slicing along different axes can provide a useful perspective. However, unequal sampling rates can create distorted images.

Changing the aspect ratio can address this by increasing the width of one of the dimensions.

For this exercise, plot images that slice along the second and third dimensions of vol. Explicitly set the aspect ratio to generate undistorted images.

Bu egzersiz

Biomedical Image Analysis in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Slice a 2D plane from vol where "axis 1" is 256.
  • Slice a 2D plane from vol where "axis 2" is 256.
  • For each image, calculate the aspect ratio by dividing the image "sampling" rate for axis 0 by its opponent axis. This information is in vol.meta.
  • Plot the images in a subplots array. Specify the aspect ratio for each image, and set cmap='gray'.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Select frame from "vol"
im1 = vol[:, 256, :]
im2 = ____

# Compute aspect ratios
d0, d1, d2 = ____
asp1 = d0 / d2
asp2 = ____

# Plot the images on a subplots array 
fig, axes = plt.subplots(nrows=2, ncols=1)
axes[0].imshow(im1, cmap='gray', ____)
____
plt.show()
Kodu Düzenle ve Çalıştır