In [1]:
import cv2
In [2]:
# read the image as a grayscale
image = cv2.imread('car.jpg',0)

cv2.ADAPTIVE_THRESH_MEAN_C - Threshold value is the mean of neighbourhood area.

cv2.ADAPTIVE_THRESH_GAUSSIAN_C - Threshold value is the weighted sum of neighbourhood values where weights are a gaussian window.

Block Size - It decides the size of neighbourhood area.

C - It is just a constant which is subtracted from the mean or weighted mean calculated.

In [3]:
th1 = cv2.adaptiveThreshold(image, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY,11,2)
th2 = cv2.adaptiveThreshold(image, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,11,2)
In [4]:
cv2.imshow("Adaptive Mean Thresholding", th1)
cv2.imshow("Adaptive Gaussian Thresholding", th2)