import cv2
import numpy as np
img1 = cv2.imread("black.jpg")
img=cv2.cvtColor(img1,cv2.COLOR_BGR2GRAY)
#hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
#mask = cv2.inRange(hsv, lower_red, upper_red)
#img = cv2.bitwise_and(img, img, mask=mask)
#kernel = np.ones((15, 15), np.float64)/225
#blur = cv2.GaussianBlur(img, (5,5), 0)
#ret3,th3 = cv2.threshold(blur,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
bilateral=cv2.bilateralFilter(img,25,25,25) #eats a lot of processing power
edgesbilateral=cv2.Canny(bilateral,135,135)
#edgesblur=cv2.Canny(blur,50,50)
#edges=cv2.Canny(img,50,50)
ret, thresh = cv2.threshold(img, 130, 255, 0)
_,contours,h=cv2.findContours(thresh,2,1)
#gaus=cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,199,1)
kernel=np.ones((2,2),np.uint8)
#opening=cv2.morphologyEx(thresh,cv2.MORPH_OPEN,kernel)
#closing=cv2.morphologyEx(opening,cv2.MORPH_CLOSE,kernel)
contours=cv2.drawContours(thresh,contours, -1, (0,255,0), 3)
blur=cv2.GaussianBlur(thresh, (3,3), 0)
cv2.imshow('img', img)  
cv2.imshow('bi',bilateral)  
cv2.imshow('blur',blur)
#cv2.imshow('otsu',th3)
#cv2.imshow('gaus',edgesblur)
#cv2.imshow('bilateral',edgesbilateral) 
#cv2.imshow('imge', edges) 
#cv2.imshow('gaus',gaus)
cv2.imshow('cont',contours)
cv2.imshow('thresh',thresh)
cv2.waitKey(0)  
cv2.destroyAllWindows()
