Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

why my binariation image appears like this ?

1 vue (au cours des 30 derniers jours)
Bekhtaoui Abdelhakim
Bekhtaoui Abdelhakim le 27 Mai 2019
Clôturé : MATLAB Answer Bot le 20 Août 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 commentaire
Walter Roberson
Walter Roberson le 27 Mai 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.

Réponses (0)

Cette question est clôturée.

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by