Skip to content

Instantly share code, notes, and snippets.

View letthedataconfess's full-sized avatar
🎯
Focusing

Let The Data Confess letthedataconfess

🎯
Focusing
View GitHub Profile
img_t = cv2.imread("frag.png")
img1 = cv2.cvtColor(img_t, cv2.COLOR_BGR2GRAY)
thresh7 = cv2.adaptiveThreshold(img1, 255, cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY, 121,15)
cv2.imshow('text',thresh7)
cv2.waitKey(0)
cv2.destroyAllWindows()
ret, thresh6 = cv2.threshold(img, 200, 255, cv2.THRESH_TOZERO_INV) ## threshold=200
cv2.imshow('zebra',thresh6)
cv2.waitKey(0)
cv2.destroyAllWindows()
ret, thresh5 = cv2.threshold(img, 100, 255, cv2.THRESH_TOZERO)
cv2.imshow('zebra',thresh5)
cv2.waitKey(0)
cv2.destroyAllWindows()
ret, thresh4 = cv2.threshold(img, 90, 255, cv2.THRESH_TRUNC) ##thresh=90
cv2.imshow('zebra',thresh4)
cv2.waitKey(0)
cv2.destroyAllWindows()
ret, thresh3 = cv2.threshold(img, 60, 255, cv2.THRESH_BINARY_INV) ##inverted_binary_threshold=60
cv2.imshow('zebra',thresh3)
cv2.waitKey(0)
cv2.destroyAllWindows()
ret, thresh2 = cv2.threshold(img, 60, 255, cv2.THRESH_BINARY_INV) ##inverted_binary_threshold=60
cv2.imshow('zebra',thresh2)
cv2.waitKey(0)
cv2.destroyAllWindows()
ret, thresh1 = cv2.threshold(img, 60, 255, cv2.THRESH_BINARY) ##threshold=60
cv2.imshow('zebra',thresh1)
cv2.waitKey(0)
cv2.destroyAllWindows()
edges = cv2.Canny(img,100,500)
plt.imshow(edges,cmap = 'gray')
plt.title('Edge Image'), plt.xticks([]), plt.yticks([])
plt.show()
edges = cv2.Canny(img,100,200)
plt.imshow(edges,cmap = 'gray')
plt.title('Edge Image'), plt.xticks([]), plt.yticks([])
plt.show()
@letthedataconfess
letthedataconfess / image_histogram.py
Last active September 20, 2021 01:52
opencv part 1
img = cv.imread('zebra.jpg',0)
hist = cv.calcHist([img],[0],None,[256],[0,256])
plt.hist(img.ravel(),256,[0,256])
plt.show()