adaptivethresholdcv
Applies adaptive threshold to the image, handle.
Syntax
R = adaptivethresholdcv(handle, max, method, type, blocksize, cvalue)
Inputs
- handle
- Handle of a single channel (grayscale) image or a 2D, real matrix.
- max
- Non-zero max value applied to the affected pixels of handle.
- method
- Adaptive threshold method. Valid values are:
- 0
- Type cv::ADAPTIVE_THRESH_MEAN_C.
- 1
- Type cv::ADAPTIVE_THRESH_GAUSSIAN_C
- type
- Threshold type. Valid values are:
- 0
- Type cv::THRESH_BINARY.
- 1
- Type cv::THRESH_BINARY_INV
- blocksize
- Size of pixel neighborhood.
- cvalue
- Constant subtracted from mean or weighted mean.
Outputs
- R
- Handle of the output image.
Example
src = imreadcv('bird1.jpg', 0);
m = 100;
method = 1;
ttype = 0;
blocksize = 3;
constantval = 5;
R = adaptivethresholdcv(src, m, method, ttype, blocksize, constantval);
imgoriginal = imreadcv('adaptivethresholdcv_fig3.png',1);
figure(1);
imshowcv(imgoriginal);
%Conver the image to gray scale
img = cvtcolorcv(imgoriginal, 6);
%Apply thresholding technique
thresh = adaptivethresholdcv(img, 255, 0,0, 199, 5)
figure(2);
imshowcv(thresh);