Search code examples
matlabopencvadaptive-threshold

Adaptive thresholding Matlab-Opencv


I wanted to apply cv.adaptiveThreshold (opencv) through matlab on 8-bit single-channel uint8 image but I am always getting error. I have tried following code from this website: https://kyamagu.github.io/mexopencv/matlab/adaptiveThreshold.html

th = cv.adaptiveThreshold(img,255,'Method',mean,'Type',binary,3,2);

and it gives me the error of Not enough input argument. when I am running like this:

th = cv.adaptiveThreshold(img);

it is working properly but this is not what I want. I don't want to apply default methods and criteria.

Thanks for the help.


Solution

  • Read the documentation. You are not following the function argument list

    cv.adaptiveThreshold(img,'MaxValue',255,'Method','Mean','Type','Binary','BlockSize',3,'C',2);
    

    should work