-
-
Save Praveen76/cd40824fdbb4b14d7a88b156f6c95063 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
img=cv.imread('D:\image.jpg') | |
cv.imshow('img',img) | |
img=cv.cvtColor(img,cv.COLOR_BGR2GRAY) | |
ret,thresh1 = cv.threshold(img,120,255, cv.THRESH_BINARY) | |
ret,thresh2 = cv.threshold(img,120,255, cv.THRESH_BINARY_INV) | |
ret,thresh3 = cv.threshold(img,120,255, cv.THRESH_TRUNC) | |
ret,thresh4 = cv.threshold(img,120,255, cv.THRESH_TOZERO) | |
ret,thresh5 = cv.threshold(img,120,255, cv.THRESH_TOZERO_INV) | |
#Windows showing output images with the corresponding thresholding techniques applied to the input images | |
cv.imshow('Binary Threshold',thresh1) | |
cv.imshow('Binary Threshold Inverted',thresh2) | |
cv.imshow('Truncated Threshold',thresh3) | |
cv.imshow('Set to 0',thresh4) | |
cv.imshow('Set to 0 Inverted',thresh5) | |
#Deallocate any associated memory usage | |
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