March 2019
Intermediate to advanced
532 pages
13h 2m
English
In order to test scikit-image, we are going to threshold a test image using Otsu's binarization algorithm. In order to try this method, the first step is to import the required packages. In this case, in connection with scikit-image as follows:
from skimage.filters import threshold_otsufrom skimage import img_as_ubyte
The key code to apply Otsu's binarization algorithm with scikit-image is the following:
thresh = threshold_otsu(gray_image)binary = gray_image > threshbinary = img_as_ubyte(binary)
The threshold_otsu(gray_image) function returns the threshold value based on Otsu's binarization algorithm. Afterwards, with this value, the binary image is constructed (dtype= bool), which should be converted ...