[sdf -> bsdf] Fix edge detection bug.

* src/sdf/ftbsdf.c (bsdf_is_edge): [BUG] Check all
  neighbors including the diagonal neighbors to
  properly determine the edge.
This commit is contained in:
Anuj Verma 2020-07-27 10:56:40 +05:30 committed by anujverma
parent f057095bef
commit 262e9649f3
2 changed files with 58 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2020-07-27 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Fix edge detection bug.
* src/sdf/ftbsdf.c (bsdf_is_edge): [BUG] Check all
neighbors including the diagonal neighbors to
properly determine the edge.
2020-07-27 Anuj Verma <anujv@iitbhilai.ac.in> 2020-07-27 Anuj Verma <anujv@iitbhilai.ac.in>
[sdf -> bsdf] Added edge detection algorithm. [sdf -> bsdf] Added edge detection algorithm.

View File

@ -107,6 +107,7 @@
FT_Byte* to_check = NULL; FT_Byte* to_check = NULL;
FT_Int num_neighbour = 0; FT_Int num_neighbour = 0;
if ( y == 7 && x == 20 ) if ( y == 7 && x == 20 )
to_check = NULL; to_check = NULL;
@ -117,7 +118,7 @@
if ( y > 0 ) if ( y > 0 )
{ {
num_neighbour++; num_neighbour++;
to_check = s - w; to_check = s - w;
if ( *to_check == 0 ) if ( *to_check == 0 )
{ {
is_edge = 1; is_edge = 1;
@ -161,9 +162,55 @@
} }
} }
/* up left */
if ( y > 0 && x > 0 )
{
num_neighbour++;
to_check = s - w - 1;
if ( *to_check == 0 )
{
is_edge = 1;
goto Done;
}
}
if ( num_neighbour != 4 ) /* up right */
if ( y > 0 && x < w - 2 )
{
num_neighbour++;
to_check = s - w + 1;
if ( *to_check == 0 )
{
is_edge = 1;
goto Done;
}
}
/* down left */
if ( y < r - 2 && x > 0 )
{
num_neighbour++;
to_check = s + w - 1;
if ( *to_check == 0 )
{
is_edge = 1;
goto Done;
}
}
/* down right */
if ( y < r - 2 && x < w - 2 )
{
num_neighbour++;
to_check = s + w + 1;
if ( *to_check == 0 )
{
is_edge = 1;
goto Done;
}
}
if ( num_neighbour != 8 )
is_edge = 1; is_edge = 1;
Done: Done: