PyImageSearch
pyimagesearch.com โบ home โบ blog โบ adaptive thresholding with opencv ( cv2.adaptivethreshold )
Adaptive Thresholding with OpenCV ( cv2.adaptiveThreshold ) - PyImageSearch
June 9, 2023 - The fourth value to cv2.adaptiveThreshold is the threshold method, again just like the simple thresholding and Otsu thresholding methods. Here we pass in a value of cv2.THRESH_BINARY_INV to indicate that any pixel value that passes the threshold test will have an output value of 0.
OpenCV-Python Tutorials
opencv24-python-tutorials.readthedocs.io โบ en โบ latest โบ py_tutorials โบ py_imgproc โบ py_thresholding โบ py_thresholding.html
Image Thresholding โ OpenCV-Python Tutorials beta documentation
Adaptive Method - It decides how thresholding value is calculated. cv2.ADAPTIVE_THRESH_MEAN_C : threshold value is the mean of neighbourhood area.
08:47
Python OpenCV Thresholding: From Simple to Adaptive in Minutes! ...
10:03
OpenCV Python Tutorial For Beginners 15 - Adaptive Thresholding ...
07:46
Adaptive Thresholding Techniques in OpenCV ๐ฒ || python for ...
OpenCV Python Adaptive Thresholding
14:17
OPENCV & C++ TUTORIALS - 24 | cv::adaptiveThreshold | Detaily ...
OpenCV
docs.opencv.org โบ 4.13.0 โบ d7 โบ d4d โบ tutorial_py_thresholding.html
OpenCV: Image Thresholding
In the previous section, we used ... in different areas. In that case, adaptive thresholding can help. Here, the algorithm determines the threshold for a pixel based on a small region around it....
TutorialsPoint
tutorialspoint.com โบ opencv โบ opencv_adaptive_threshold.htm
OpenCV - Adaptive Threshold
In OpenCV, you can perform Adaptive threshold operation on an image using the method adaptiveThreshold() of the Imgproc class.
Stack Abuse
stackabuse.com โบ opencv-adaptive-thresholding-in-python-with-cv2adaptivethreshold
OpenCV Adaptive Thresholding in Python with cv2.adaptiveThreshold()
November 16, 2023 - In much the same way, we can apply Gaussian thresholding: mask = cv2.adaptiveThreshold(blurred, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 31, 10)
Medium
medium.com โบ featurepreneur โบ dive-deeper-into-opencvs-adaptive-thresholding-3f29dda8c908
Dive deeper into OpenCVโs Adaptive Thresholding | by Maximin Joshua | featurepreneur | Medium
December 1, 2021 - Then depending on the threshold type passed, either one of the following operations in the below image is performed: ... import cv2 as cv#read an image and convert it to grayscale img = cv.imread('D://medium_blogs//phone_dimmed4.jpg') gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)#apply normal and adaptive thresholding to the image ret, thresh = cv.threshold(gray, 70, 255, cv.THRESH_BINARY) adapt = cv.adaptiveThreshold(gray,255,cv.ADAPTIVE_THRESH_MEAN_C,cv.THRESH_BINARY,99,3)#create resizable windows for the images to be displayed cv.namedWindow('adapt',cv.WINDOW_NORMAL) cv.namedWindow('thresh', cv.WINDOW_NORMAL)#show the image cv.imshow('thresh', thresh) cv.imshow('adapt', adapt)if cv.waitKey(0): cv.destroyAllWindows()
Top answer 1 of 2
23
Python: cv2.adaptiveThreshold(src, maxValue, adaptiveMethod, thresholdType, blockSize, C[, dst]) โ dst
Parameters:
src โ Source 8-bit single-channel image.
dst โ Destination image of the same size and the same type as src .
maxValue โ Non-zero value assigned to the pixels for which the condition is satisfied. See the details below.
adaptiveMethod โ Adaptive thresholding algorithm to use, ADAPTIVE_THRESH_MEAN_C or ADAPTIVE_THRESH_GAUSSIAN_C . See the details below.
thresholdType โ Thresholding type that must be either THRESH_BINARY or THRESH_BINARY_INV .
blockSize โ Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.
C โ Constant subtracted from the mean or weighted mean (see the details below). Normally, it is positive but may be zero or negative as well.
Taken from here: and it also explains the method in a lot more detail.
2 of 2
4
Add to the answer from GPPK.
The function transforms a grayscale image to a binary image according to the formulae:
- THRESH_BINARY

- THRESH_BINARY_INV

where T(x,y) is a threshold calculated individually for each pixel.
- For the method ADAPTIVE_THRESH_MEAN_C , the threshold value T(x,y) is a mean of the blockSize x blockSize neighborhood of (x, y) minus C .
- For the method ADAPTIVE_THRESH_GAUSSIAN_C , the threshold value T(x, y) is a weighted sum (cross-correlation with a Gaussian window) of the blockSize x blockSize neighborhood of (x, y) minus C . The default sigma (standard deviation) is used for the specified blockSize .
Stack Overflow
stackoverflow.com โบ questions โบ 77978648 โบ shape-detection-with-adaptive-thresholding-in-python-opencv
Shape Detection with Adaptive Thresholding in Python/OpenCV - Stack Overflow
As fmw42 mentioned, the best answers are the simplest. cv2.adaptiveThreshold is not an easy function to use and in this case, the obvious approach should be to go with colour channels instead of dynamic thresholds
OpenCV
opencv.org โบ home โบ news โบ image thresholding using opencv
Image Thresholding using OpenCV
April 24, 2025 - The initial threshold value (0 here) is ignored and OpenCV calculates the best threshold internally and returns it as the first output (_ in this case). import cv2 # Load image in grayscale img = cv2.imread("intensity_digits.png", cv2.IMREAD_GRAYSCALE) # Adaptive Mean Thresholding thresh_mean = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 11, 2) # Adaptive Gaussian Thresholding thresh_gauss = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2) # Otsu's Thresholding _, thresh_otsu = cv2.threshold(img, 0, 255, cv2.THRESH_BIN
YouTube
youtube.com โบ watch
OpenCV - Adaptive Thresholding - YouTube
This video shows you how to use OpenCV's Adaptive Threshold function.Adaptive Thresholding Paper Link: https://people.scs.carleton.ca/~roth/iit-publications-
Published: April 4, 2020
Pseudopencv
pseudopencv.site โบ utilities โบ adaptthreshold
Adaptive Image Thresholding
The adaptive algorithm to use. Check out the Adaptive Threshold Type for more detail explanation. Type of algorithm use to calculate the threshold. Check out the documentation for further information on each type. Unlike the normal cv2.threshold(), only limited amount of threshold type is supported.


