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

Calculate distance

A distance transformation calculates the distance from each pixel to a given point, usually the nearest background pixel. This allows you to determine which points in the object are more interior and which are closer to edges.

For this exercise, use the Euclidian distance transform on the left ventricle object in labels.

Bu egzersiz

Biomedical Image Analysis in Python

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

Egzersiz talimatları

  • Create a mask of left ventricle pixels (Value of 1 in labels).
  • Calculate the distance to background for each pixel using ndi.distance_transform_edt(). Supply pixel dimensions to the sampling argument.
  • Print out the maximum distance and its coordinates using ndi.maximum and ndi.maximum_position.
  • Overlay a slice of the distance map on the original image. This has been done for you.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Calculate left ventricle distances
lv = np.where(____, 1, 0)
dists = ____

# Report on distances
print('Max distance (mm):', ____)
print('Max location:', ____)

# Plot overlay of distances
overlay = np.where(dists[5] > 0, dists[5], np.nan) 
plt.imshow(overlay, cmap='hot')
format_and_render_plot()
Kodu Düzenle ve Çalıştır