Info

This question is closed. Reopen it to edit or answer.

why my binariation image appears like this ?

2 views (last 30 days)
Bekhtaoui Abdelhakim
Bekhtaoui Abdelhakim on 27 May 2019
Closed: MATLAB Answer Bot on 20 Aug 2021
hi evreyone please someone can tel me why my image after adaptive thres operation appears like that and how can i remove this white boundary ??
the code:
function [o] = adaptiveThres(a,W,noShow)
W=16;
%adaptiveThres(a,W);
[w,h] = size(a);
o = zeros(w,h);
%seperate it to W block
%step to w with step length W
for i=1:W:w
for j=1:W:h
mean_thres = 0;
%white is ridge -> large
if i+W-1 <= w & j+W-1 <= h
mean_thres = mean2(a(i:i+W-1,j:j+W-1));
%threshold value is choosed
mean_thres = 0.8*mean_thres;
%before binarization
%ridges are black, small intensity value -> 1 (white ridge)
%the background and valleys are white, large intensity value -> 0(black)
o(i:i+W-1,j:j+W-1) = a(i:i+W-1,j:j+W-1) < mean_thres;
end;
end;
end;
if nargin == 2
imshow(o);
imwrite(o,'C:\Users\home\Documents\PFE\method\BINimg.jpg');
end
thanks for helping
  1 Comment
Walter Roberson
Walter Roberson on 27 May 2019
%seperate it to W block
That should tell you right there why you are having the problem. You are dividing the image up into W blocks by W blocks, and processing each one separately. The result is going to be blocky. You could reduce the size of the white border by increasing W.

Answers (0)

This question is closed.

Products


Release

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!