[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] anuj-distance-field f057095 79/93: [sdf -> bsdf] Added edge
From: |
Anuj Verma |
Subject: |
[freetype2] anuj-distance-field f057095 79/93: [sdf -> bsdf] Added edge detection algorithm. |
Date: |
Sun, 2 Aug 2020 07:04:28 -0400 (EDT) |
branch: anuj-distance-field
commit f057095bef5133f152f56c560fc0e30e8a85262b
Author: Anuj Verma <anujv@iitbhilai.ac.in>
Commit: anujverma <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.
---
[GSoC]ChangeLog | 12 +++++++
src/sdf/ftbsdf.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 106 insertions(+), 3 deletions(-)
diff --git a/[GSoC]ChangeLog b/[GSoC]ChangeLog
index ae4cae0..9d15fea 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 caa1acf..004346a 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
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] anuj-distance-field f057095 79/93: [sdf -> bsdf] Added edge detection algorithm.,
Anuj Verma <=