Edges Examples¶
[1]:
from easycv import Image
from easycv.io.output import show_grid
from easycv.transforms import Gradient, GradientAngle, Canny
For this example we will load an image from the Dog API. For more examples of image loading check Image examples.
[2]:
img = Image("https://images.dog.ceo/breeds/sheepdog-english/n02105641_1045.jpg")
img
[2]:

Gradient¶
To calculate the gradient of the image we simply apply the Gradient Transform for both axis, for more information check the reference. The gradients are displayed in a grid created using show_grid().
[3]:
grad_x = img.apply(Gradient(axis="x"))
grad_y = img.apply(Gradient(axis="y"))
show_grid([grad_x,grad_y])

Gradient Magnitude¶
To calculate the magnitude of the image gradient we simply apply the Gradient transform with no axis, for more information check the reference.
[4]:
img.apply(Gradient())
[4]:

Gradient Angle¶
To calculate the angles of the image gradient we simply apply the GradientAngle transform, for more information check the reference.
[5]:
img.apply(GradientAngle(size=1))
[5]:

Canny Edge¶
To get the edges of an image we just apply the Canny transform with the low and high threshold, for more information check the reference.
[6]:
img.apply(Canny(low=100, high=200))
[6]:
