What is this filtering algorithm called?

Hello, can somebody explain to me how the following code works or tell me the name of the method used to filter the left binary image to the right one?
Image:
Code:
[rows, cols] = size(e);
L1 = 20;
L2 = 80;
seed = [];
for alpha = 40:120
dx = cos( alpha * pi / 180);
dy = sin( alpha * pi / 180);
for d = L1:L2
r = round(cy - d * dy );
c = round(cx + d * dx );
found = 0;
for i = -2:2
for j=-2:2
ri = r + i;
cj = c + j;
if( ri < 1 || ri > rows || cj < 1 || cj > cols || found )
continue;
end;
if( e(ri, cj) )
found = 1;
seed = [ seed, sub2ind( [rows, cols], ri, cj ) ];
end;
end;
end;
if( found>0 )
break;
end;
end;
end;
newe = ones( rows, cols ) > 2;
for k=1:length(seed)
[r,c] = ind2sub( [rows, cols], seed(k) );
if( e(r,c) )
e(r,c) = 0;
q = seed(k);
newe(r,c) = 1;
while( ~isempty(q) )
id = q(1); q = q(2:end);
[r,c] = ind2sub( [rows, cols],id);
for i=-1:1
for j=-1:1
ri = r+i;
cj = c+j;
if( ri < 1 || ri > rows || cj < 1 || cj > cols )
continue;
end;
if( e(ri, cj) )
e(ri, cj) = 0;
newe( ri, cj ) = 1;
q = [q, sub2ind( [rows, cols], ri, cj ) ];
end;
end;
end;
end;
end;
end;
newe = bwmorph( newe, 'dilate', 2 );
newe = bwmorph( newe, 'thin', inf );

Answers (0)

This question is closed.

Asked:

on 7 Jan 2014

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!