Skip to content
Related Articles
Open in App
Not now

Related Articles

Mahotas – Edges using Difference of Gaussian for binary image

Improve Article
Save Article
  • Last Updated : 10 Jul, 2020
Improve Article
Save Article

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




# importing required libraries
import mahotas as mh
import numpy as np
from pylab import imshow, show
    
# creating region
# numpy.ndarray
regions = np.zeros((10, 10), bool)
    
# setting 1 value to the region
regions[:3, :3] = 1
regions[6:, 6:] = 1
    
# getting labeled function
labeled, nr_objects = mh.label(regions)
    
# showing the image with interpolation = 'nearest'
print("Binary Image")
imshow(labeled, interpolation ='nearest')
show()
   
# getting edges using dog algo
dog = mahotas.dog(labeled)
   
# showing image
print("Edges using DoG algo")
imshow(dog)
show()

Output :

Binary Image

Edges using DoG algo

Another example




# importing required libraries
import mahotas as mh
import numpy as np
from pylab import imshow, show
    
# creating region
# numpy.ndarray
regions = np.zeros((10, 10), bool)
    
# setting 1 value to the region
regions[1, :2] = 1
regions[5:8, 6: 8] = 1
regions[8, 0] = 1
    
# getting labeled function
labeled, nr_objects = mh.label(regions)
    
# showing the image with interpolation = 'nearest'
print("Image")
imshow(labeled, interpolation ='nearest')
show()
   
# getting edges
dog = mahotas.dog(labeled)
   
# showing image
print("Edges using DoG algo")
imshow(dog)
show()

Output :

Binary Image

Edges using DoG algo


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!