Skip to content

vasavamsi/Python-implementation-of-Otsu-s-thresholding

Repository files navigation

https-github.com-vasavamsi-Python-implementation-of-Otsu-s-thresholding

Otsu is a thresholding method used to differentiate the pixels into foreground and background by calculating the maximum variance between both classes. The method can be further formulated to digitize the picture into more than two classes. In this file I showed the algorithm followed to code this method along with the results obtained. Instructions to use the code are also included.

I completed this code using python. I used cv2, numpy and matplotlib libraries to complete the task.

Algorithm

Step 1: Convert the input image into Grayscale.

Step 2: calculate the histogram profile and normalize.

Step 3: Multiply the histogram values with their corresponding pixel values.

Step 4: Calculate the in between variance for each pixel.

Step 5: Select the pixel value with maximum variance as the threshold to binarize the image.

For the multi-thresholding, we further consider more than one pixel value and calculate the in between variances using. My code works for the multi-thresholding with 2 and 3 levels of thresholding.

Results

results gif

#MATLAB Implementation of the Otsu Algorithm is provided here

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages