Created
October 29, 2021 11:11
-
-
Save Yuktha-Majella/09471079defb9fc0e81b5604410527a5 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 | |
import numpy as np | |
img = cv.imread('C:\\Users\\Admin\\Downloads\\thresholding\\annefrank_diary.jpg',0) | |
#Simple Thresholding | |
ret,thresh1 = cv.threshold(img,127,255,cv2.THRESH_BINARY) | |
#Different types of Adaptive Thresholding | |
thresh2 = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,11,2) | |
thresh3 = cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,11,2) | |
vis1 = np.concatenate((img, thresh1), axis=1) | |
vis2 = np.concatenate((thresh2, thresh3), axis=1) | |
cv2.imshow("ORIGINAL vs THRESH_BINARY", vis1) | |
cv2.imshow("ADAPTIVE_THRESH_MEAN_C vs ADAPTIVE_THRESH_GAUSSIAN_C", vis2) | |
cv2.waitKey(0) | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment