Info

此问题已关闭。 请重新打开它进行编辑或回答。

why my binariation image appears like this ?

1 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2019-5-27
%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.

回答(0 个)

此问题已关闭。

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by