Mahotas – Edges using Difference of Gaussian for binary image
Last Updated :
10 Jul, 2020
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.dog
method
Syntax : mahotas.dog(img)
Argument : It takes binary image object as argument
Return : It returns image object
Below is the implementation
import mahotas as mh
import numpy as np
from pylab import imshow, show
regions = np.zeros(( 10 , 10 ), bool )
regions[: 3 , : 3 ] = 1
regions[ 6 :, 6 :] = 1
labeled, nr_objects = mh.label(regions)
print ( "Binary Image" )
imshow(labeled, interpolation = 'nearest' )
show()
dog = mahotas.dog(labeled)
print ( "Edges using DoG algo" )
imshow(dog)
show()
|
Output :
Binary Image
Edges using DoG algo
Another example
import mahotas as mh
import numpy as np
from pylab import imshow, show
regions = np.zeros(( 10 , 10 ), bool )
regions[ 1 , : 2 ] = 1
regions[ 5 : 8 , 6 : 8 ] = 1
regions[ 8 , 0 ] = 1
labeled, nr_objects = mh.label(regions)
print ( "Image" )
imshow(labeled, interpolation = 'nearest' )
show()
dog = mahotas.dog(labeled)
print ( "Edges using DoG algo" )
imshow(dog)
show()
|
Output :
Binary Image
Edges using DoG algo
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...