summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnuj Verma <anujv@iitbhilai.ac.in>2020-07-27 10:25:52 +0530
committeranujverma <anujv@iitbhilai.ac.in>2020-08-02 16:33:21 +0530
commitf057095bef5133f152f56c560fc0e30e8a85262b (patch)
tree4af7545845d7d0a8c3855ae4ee5a0303c48111a4
parent8564d5caf2f8773dea70ab6722f97ba889fed8f5 (diff)
downloadfreetype2-f057095bef5133f152f56c560fc0e30e8a85262b.tar.gz
[sdf -> bsdf] Added edge detection algorithm.
Added edge detection algorithm. It works by checking the neighboring pixels and if any neighbor is not filled (i.e. belongs to background) we mark the pixel as edge by setting it's distance to 0. * src/sdf/ftbsdf.c (bsdf_is_edge): Added function to detect if the pixel is an edge.
-rw-r--r--[GSoC]ChangeLog12
-rw-r--r--src/sdf/ftbsdf.c97
2 files changed, 106 insertions, 3 deletions
diff --git a/[GSoC]ChangeLog b/[GSoC]ChangeLog
index ae4cae034..9d15fea09 100644
--- a/[GSoC]ChangeLog
+++ b/[GSoC]ChangeLog
@@ -1,5 +1,17 @@
2020-07-27 Anuj Verma <anujv@iitbhilai.ac.in>
+ [sdf -> bsdf] Added edge detection algorithm.
+
+ Added edge detection algorithm. It works by checking
+ the neighboring pixels and if any neighbor is not
+ filled (i.e. belongs to background) we mark the
+ pixel as edge by setting it's distance to 0.
+
+ * src/sdf/ftbsdf.c (bsdf_is_edge): Added function to
+ detect if the pixel is an edge.
+
+2020-07-27 Anuj Verma <anujv@iitbhilai.ac.in>
+
[sdf -> bsdf] Added the second pass of the '8SED'.
Added the second pass of the 8SED algorithm. The second pass
diff --git a/src/sdf/ftbsdf.c b/src/sdf/ftbsdf.c
index caa1acfb5..004346a04 100644
--- a/src/sdf/ftbsdf.c
+++ b/src/sdf/ftbsdf.c
@@ -85,6 +85,94 @@
/**************************************************************************
*
* @Function:
+ * bsdf_is_edge
+ *
+ * @Description:
+ * [TODO]
+ *
+ * @Input:
+ * [TODO]
+ *
+ * @Return:
+ * [TODO]
+ */
+ static FT_Bool
+ bsdf_is_edge( FT_Byte* s, /* source bitmap */
+ FT_Int x, /* x index of point to check */
+ FT_Int y, /* y index of point to check */
+ FT_Int w, /* width */
+ FT_Int r ) /* rows */
+ {
+ FT_Bool is_edge = 0;
+ FT_Byte* to_check = NULL;
+ FT_Int num_neighbour = 0;
+
+ if ( y == 7 && x == 20 )
+ to_check = NULL;
+
+ if ( *s == 0 )
+ goto Done;
+
+ /* up */
+ if ( y > 0 )
+ {
+ num_neighbour++;
+ to_check = s - w;
+ if ( *to_check == 0 )
+ {
+ is_edge = 1;
+ goto Done;
+ }
+ }
+
+ /* down */
+ if ( y < r - 2 )
+ {
+ num_neighbour++;
+ to_check = s + w;
+ if ( *to_check == 0 )
+ {
+ is_edge = 1;
+ goto Done;
+ }
+ }
+
+ /* left */
+ if ( x > 0 )
+ {
+ num_neighbour++;
+ to_check = s - 1;
+ if ( *to_check == 0 )
+ {
+ is_edge = 1;
+ goto Done;
+ }
+ }
+
+ /* right */
+ if ( x < w - 2 )
+ {
+ num_neighbour++;
+ to_check = s + 1;
+ if ( *to_check == 0 )
+ {
+ is_edge = 1;
+ goto Done;
+ }
+ }
+
+
+
+ if ( num_neighbour != 4 )
+ is_edge = 1;
+
+ Done:
+ return is_edge;
+ }
+
+ /**************************************************************************
+ *
+ * @Function:
* bsdf_init_distance_map
*
* @Description:
@@ -233,19 +321,22 @@
pixel_value <<= 8;
#else
- if ( pixel_value )
+ if ( bsdf_is_edge( s + s_index , s_i, s_j, s_width, s_rows ) )
{
t[t_index].dist = 0;
- t[t_index].sign = 1;
}
else
{
t[t_index].near.x = FT_INT_MAX;
t[t_index].near.y = FT_INT_MAX;
t[t_index].dist = 128 * ONE;
- t[t_index].sign = -1;
}
+ if ( pixel_value )
+ t[t_index].sign = 1;
+ else
+ t[t_index].sign = -1;
+
#endif
}
}