def test_hough_angles():
    img = np.zeros((10, 10))
    img[0, 0] = 1

    out, angles, d = tf.hough(img, np.linspace(0, 360, 10))

    assert_equal(len(angles), 10)
Beispiel #2
0
def ridgeDetection(image):
    from scikits.image import transform
    out, angles, d = transform.hough(errors)
    pylab.figure()
    pylab.imshow(out, cmap=pylab.cm.bone)
    pylab.xlabel('Angle (degree)')
    pylab.ylabel('Distance %d (pixel)' % d[0])
def test_hough():
    # Generate a test image
    img = np.zeros((100, 100), dtype=int)
    for i in range(25, 75):
        img[100 - i, i] = 1

    out, angles, d = tf.hough(img)

    y, x = np.where(out == out.max())
    dist = d[y[0]]
    theta = angles[x[0]]

    assert_equal(dist > 70, dist < 72)
    assert_equal(theta > 0.78, theta < 0.79)
import numpy as np
import matplotlib.pyplot as plt

# Construct test image

image = np.zeros((100, 100))


# Classic straight-line Hough transform

idx = np.arange(25, 75)
image[idx[::-1], idx] = 255
image[idx, idx] = 255

h, theta, d = hough(image)

plt.figure(figsize=(12, 5))

plt.subplot(121)
plt.imshow(image, cmap=plt.cm.gray)
plt.title('Input image')

plt.subplot(122)
plt.imshow(np.log(1 + h),
           extent=[np.rad2deg(theta[-1]), np.rad2deg(theta[0]),
                   d[-1], d[0]],
           cmap=plt.cm.gray, aspect=1/1.5)
plt.title('Hough transform')
plt.xlabel('Angles (degrees)')
plt.ylabel('Distance (pixels)')
Beispiel #5
0
diffs = []

diffmap = 255 * (abs(input_maps[1] - input_maps[0]) > diffthresh)

for i in range(0, ndiff):
    # difference map
    diffmap = 255 * (abs(input_maps[i + 1] - input_maps[i]) > diffthresh)

    # keep
    diffs.append(diffmap)

    # extract the image
    img = diffmap

    # Perform the hough transform on each of the difference maps
    transform, theta, d = hough(img)

    # Filter the hough transform results and find the best lines
    # in the data
    indices = (transform > votethresh).nonzero()
    distances = d[indices[0]]
    theta = theta[indices[1]]
    n = len(indices[1])
    print("Found " + str(n) + " lines.")

    # Perform the inverse transform to get a series of rectangular
    # images that show where the wavefront is.
    invTransform = sunpy.map.BaseMap(input_maps[i + 1])
    invTransform.data = np.zeros(imgShape)
    for i in range(0, n):
        nextLine = htLine(distances[i], theta[i], np.zeros(shape=imgShape))
Beispiel #6
0
diffs = []

temp = 255*(abs(input_maps[14] - input_maps[13]) > diffthresh)

for i in range(0,ndiff):
    # difference map
    diffmap = 255*(abs(input_maps[i+1] - input_maps[i]) > diffthresh)

    # keep
    diffs.append(diffmap)

    # extract the image
    img = diffmap

    # Perform the hough transform on each of the difference maps
    transform,theta,d = hough(img)

    # Filter the hough transform results and find the best lines
    # in the data
    indices =  (transform >votethresh).nonzero()
    distances = d[indices[0]]
    theta = theta[indices[1]]
    n =len(indices[1])
    print("Found " + str(n) + " lines.")

    # Perform the inverse transform to get a series of rectangular
    # images that show where the wavefront is.
    invTransform = sunpy.map.BaseMap(input_maps[i+1])
    invTransform.data = np.zeros(imgShape)
    for i in range(0,n):
        nextLine = htLine( distances[i],theta[i], np.zeros(shape=imgShape) )
import numpy as np
import matplotlib.pyplot as plt

from scikits.image.transform import hough

img = np.zeros((100, 150), dtype=bool)
img[30, :] = 1
img[:, 65] = 1
img[35:45, 35:50] = 1
for i in range(90):
    img[i, i] = 1
img += np.random.random(img.shape) > 0.95

out, angles, d = hough(img)

plt.subplot(1, 2, 1)

plt.imshow(img, cmap=plt.cm.gray)
plt.title('Input image')

plt.subplot(1, 2, 2)
plt.imshow(out, cmap=plt.cm.bone,
           extent=(d[0], d[-1],
                   np.rad2deg(angles[0]), np.rad2deg(angles[-1])))
plt.title('Hough transform')
plt.xlabel('Angle (degree)')
plt.ylabel('Distance (pixel)')

plt.subplots_adjust(wspace=0.4)
plt.show()