-
-
Save Praveen76/80774469c861dfb2b785e2fbfa60854a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 as cv | |
import numpy as np | |
from matplotlib import pyplot as plt | |
img=cv.imread('D:\otsu.jpg') | |
cv.imshow('park',img) | |
#gloabl thresholding | |
ret1,th1=cv.threshold(img,150,255,cv.THRESH_BINARY) | |
#OTSU Thresholding | |
ret2,th2=cv.threshold(img,0,255,cv.THRESH_BINARY+cv.THRESH_OTSU) | |
'''#OTSU Thresholding after Gaussian Filtering | |
blur=cv.GaussianBlur(img,(5,5),0) | |
ret3,th3=cv.threshold(blur,0,255,cv.THRESH_BINARY+cv.THRESH_OTSU) | |
''' | |
cv.imwrite('gloabal thresh(v=150).jpg,th1) | |
cv.imwrite('otsu binarization.jpg',th2) | |
cv.imshow('gloabal thresh(v=150)',th1) | |
cv.imshow('otsu binarization',th2) | |
cv.imshow('original',img) | |
if cv.waitKey(0) & 0*ff==27: | |
cv.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment