Code covered by the BSD License  

Highlights from
Automata Engineer 2010 NITK- Documented version

image thumbnail

Automata Engineer 2010 NITK- Documented version

by

 

The documented version of the code which solves the problem statement of Automata Engineer 2010 NITK

imt=niblack(im,k,N)
function imt=niblack(im,k,N)
% Niblack's method
% im = grayscale image

% Calculate local means and variance
localMean= filter2(ones(N), im) / (N*N);
localVar= filter2(ones(N), (double(im)-localMean).^2) /(N*N);
localStd=sqrt(localVar);

%Find threshold levels
weight=k;
tp=localMean+weight*localStd;
tm=localMean-weight*localStd;

%apply thresholds and store all three layers in one image
i1=(im>tp)*255;
i2=((im>tm)&(im<tp))*100;
imt=i1+i2;

Contact us