This is an implementation of a traditional Niblack local image thresholding with an integral image method, which guarantees constant computation time regardless of the neighborhood size.
The method can be described like:
if pixel > (mean + k * standard_deviation)
pixel = object;
pixel = background;
Better code illustration.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.