Mahotas – Edges using Difference of Gaussian for binary image
In this article we will see how we can edges of the binary image in mahotas with the help of DoG algorithm. In imaging science, difference of Gaussians (DoG) is a feature enhancement algorithm that involves the subtraction of one blurred version of an original image from another, less blurred version of the original.
In order to do this we will use
mahotas.dogmethodAttention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Syntax : mahotas.dog(img)
Argument : It takes binary image object as argument
Return : It returns image object
Below is the implementation
# importing required librariesimport mahotas as mhimport numpy as npfrom pylab import imshow, show # creating region# numpy.ndarrayregions = np.zeros((10, 10), bool) # setting 1 value to the regionregions[:3, :3] = 1regions[6:, 6:] = 1 # getting labeled functionlabeled, nr_objects = mh.label(regions) # showing the image with interpolation = 'nearest'print("Binary Image")imshow(labeled, interpolation ='nearest')show() # getting edges using dog algodog = mahotas.dog(labeled) # showing imageprint("Edges using DoG algo")imshow(dog)show() |
Output :
Binary Image

Edges using DoG algo
Another example
# importing required librariesimport mahotas as mhimport numpy as npfrom pylab import imshow, show # creating region# numpy.ndarrayregions = np.zeros((10, 10), bool) # setting 1 value to the regionregions[1, :2] = 1regions[5:8, 6: 8] = 1regions[8, 0] = 1 # getting labeled functionlabeled, nr_objects = mh.label(regions) # showing the image with interpolation = 'nearest'print("Image")imshow(labeled, interpolation ='nearest')show() # getting edgesdog = mahotas.dog(labeled) # showing imageprint("Edges using DoG algo")imshow(dog)show() |
Output :
Binary Image

Edges using DoG algo


