Python edge detection and curvature calculation

We have segmentation and edge detection algorithms in the actively developed scikit-image that you may find useful:

Scikit Images Examples


You can easily achieve edge detection with scipy in python.

from scipy import ndimage
edge_horizont = ndimage.sobel(greyscale, 0)
edge_vertical = ndimage.sobel(greyscale, 1)
magnitude = np.hypot(edge_horizont, edge_vertical)

And here is an example of original image and the image after edge detection. enter image description here

In scikit-image, there is a special page with explanations of how to do edge detection.


There is a very simple way to find contours in python with scikit image. It's really just a couple line of code, like this:

    from skimage import measure
    contours = measure.find_contours(gimg, 0.8)

This returns the vector representation of the contour lines. In a separate array for each line. And it's also easy to decrease the number of points in a line by calculating an approximation. Here is a bit longer description with source code: image vectorization with python