Mahotas – Distance from binary image
In this article we will see how we can obtain distance map of binary image in mahotas. A distance transform, also known as distance map or distance field, is a derived representation of a digital image. The choice of the term depends on the point of view on the object in question: whether the initial image is transformed into another representation, or it is simply endowed with an additional map or field.
In order to do this we will use mahotas.distance method
Syntax : mahotas.distance(img)
Argument : It takes image object which should be binary as argument
Return : It returns image object
Note : Input image should be binary image it can be labeled as well, image should be filtered or should be loaded as grey to make it binary
In order to filter the image we will take the image object which is numpy.ndarray and filter it with the help of indexing, below is the command to do this
image = image[:, :, 0]
Attention 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