I am kind of new to Matlab and trying to implement Local Sauvola Image Thresholding Algorithm. But I am getting a complete white output as result. This is my code;
function sauvola(axFiltered)
global imgGray;
global imgFiltered;
k = 0.5;
R = 128;
n = 5;
imgGray = double(imgGray);
imgFiltered = colfilt(imgGray, [n,n], 'sliding', @(x) ...
(mean(x).*(1+k*(std(x)/R-1))));
if imgGray < imgFiltered
imgGray = 0;
end
if imgGray >= imgFiltered
imgGray = 255;
end
axes(axFiltered);
imshow(imgGray);
end
I send lena.jpg as image to process but result image is all blank and completely white. I don't know what is wrong. Also I get an output for this; output
I convert image into gray in another function and it works correctly. I checked that too. Thank you in advance.