File: eccentricity_transform.py

package info (click to toggle)
libvigraimpex 1.11.1%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 50,356 kB
  • sloc: cpp: 57,785; python: 8,603; ansic: 1,798; makefile: 97; javascript: 65; sh: 50
file content (26 lines) | stat: -rw-r--r-- 725 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import vigra
import numpy
import matplotlib.pyplot as plt

f = "islands.png"
cmap = plt.get_cmap("afmhot")

# Compute labeled iamge.
img = numpy.squeeze(vigra.readImage(f))
lbl = numpy.array(vigra.analysis.labelImage(img))

# Compute the eccentricity transform.
ecc = vigra.filters.eccentricityTransform(lbl)
plt.imshow(numpy.swapaxes(ecc, 1, 0), cmap=cmap)
plt.show()

# Compute the eccentricity centers and draw them into the image.
centers = vigra.filters.eccentricityCenters(lbl)
m = ecc.max()
for c in centers[1:]:
    ecc[c] = m
plt.imshow(numpy.swapaxes(ecc, 1, 0), cmap=cmap)
plt.show()

# # Compute the transformation and the centers in one step:
# ecc, centers = vigra.filters.eccentricityTransformWithCenters(lbl)