I have a binary image of 200 rows and 200 columns. I need to find the distance between two white (255) pixel along the row and column. If the distance is 3 , i need to fill the gap along row and column with ones. I tried something but it doesnt work well. Can anyone please help me ?
vess is the binary output.
[M N]=size(vess);
[x y]=find(vess); points = [ x y]; [~,ii] = sort(points(:,1)); out = points(ii,:);% for i=1:M
[M1 N1]=size(points);% u=2;
for i=1:M1-1 C=[out(i,1),out(i,2);out(i+1,1),out(i+1,2)]; d = round(pdist(C,'euclidean')) if d==3 p1=[out(i,1),out(i,2)]; p2=[out(i+1,1),out(i+1,2)]; if p1(1)==p2(1) vess(p1(1),p1(2)+1:p2(2)+1)=1; end if p2(2)==p1(2) vess(p1(1)+1,p1(1):p2(1)+1)=1; end end end
Best Answer