1
- /*
1
+ /*
2
2
* SOD - An Embedded Computer Vision & Machine Learning Library.
3
- * Copyright (C) 2018 PixLab| Symisc Systems. https://sod.pixlab.io
4
- * Version 1.1.7
3
+ * Copyright (C) 2018 - 2019 PixLab| Symisc Systems. https://sod.pixlab.io
4
+ * Version 1.1.8
5
5
*
6
6
* Symisc Systems employs a dual licensing model that offers customers
7
7
* a choice of either our open source license (GPLv3) or a commercial
30
30
* You should have received a copy of the GNU General Public License
31
31
* along with SOD. If not, see <http://www.gnu.org/licenses/>.
32
32
*/
33
- /* $SymiscID: sod.c v1.1.7 Win10 2018-02-02 05:34 stable <[email protected] > $ */
33
+ /* $SymiscID: sod.c v1.1.8 Win10 2018-02-02 05:34 stable <[email protected] > $ */
34
34
#ifdef _MSC_VER
35
35
#ifndef _CRT_SECURE_NO_WARNINGS
36
36
/*
@@ -9701,7 +9701,7 @@ static int hilditch_func_nc8(int *b)
9701
9701
*/
9702
9702
sod_img sod_hilditch_thin_image (sod_img im )
9703
9703
{
9704
- /* thinning of binary image by Hilditch's algorithm */
9704
+ /* thinning of binary image via Hilditch's algorithm */
9705
9705
int offset [9 ][2 ] = { { 0 ,0 },{ 1 ,0 },{ 1 ,-1 },{ 0 ,-1 },{ -1 ,-1 },
9706
9706
{ -1 ,0 },{ -1 ,1 },{ 0 ,1 },{ 1 ,1 } }; /* offsets for neighbors */
9707
9707
int n_odd [4 ] = { 1 , 3 , 5 , 7 }; /* odd-number neighbors */
@@ -10666,6 +10666,94 @@ static void canny_hysteresis(int high, int low, sod_img * img_in, sod_img * img_
10666
10666
}
10667
10667
}
10668
10668
}
10669
+ /* Based on the work: http://cis.k.hosei.ac.jp/~wakahara/ */
10670
+ static int minutiae_crossnumber (float * pixels ,int y , int x , int w )
10671
+ {
10672
+ int i , data [8 ];
10673
+ int cross ;
10674
+
10675
+ data [0 ] = pixels [y * w + x + 1 ] == 0 ? 1 : 0 ;
10676
+ data [1 ] = pixels [(y - 1 ) * w + x + 1 ] == 0 ? 1 : 0 ;
10677
+ data [2 ] = pixels [(y - 1 ) * w + x ] == 0 ? 1 : 0 ;
10678
+ data [3 ] = pixels [(y - 1 ) * w + (x - 1 )] == 0 ? 1 : 0 ;
10679
+ data [4 ] = pixels [y * w + (x - 1 )] == 0 ? 1 : 0 ;
10680
+ data [5 ] = pixels [(y + 1 ) * w + (x - 1 )] == 0 ? 1 : 0 ;
10681
+ data [6 ] = pixels [(y + 1 ) * w + x ] == 0 ? 1 : 0 ;
10682
+ data [7 ] = pixels [(y + 1 ) * w + x + 1 ] == 0 ? 1 : 0 ;
10683
+ cross = 0 ;
10684
+ for (i = 0 ; i < 8 ; i ++ ) {
10685
+ cross += abs (data [(i + 1 ) % 8 ] - data [i ]);
10686
+ }
10687
+ cross /= 2 ;
10688
+ return cross ;
10689
+ }
10690
+ /*
10691
+ * CAPIREF: Refer to the official documentation at https://sod.pixlab.io/api.html for the expected parameters this interface takes.
10692
+ */
10693
+ SOD_APIEXPORT sod_img sod_minutiae (sod_img bin , int * pTotal , int * pEp , int * pBp )
10694
+ {
10695
+ if (pTotal ) {
10696
+ * pTotal = 0 ;
10697
+ }
10698
+ if (pEp ) {
10699
+ * pEp = 0 ;
10700
+ }
10701
+ if (pBp ) {
10702
+ * pBp = 0 ;
10703
+ }
10704
+ /* Extraction of minutiae candidates in skeletonized fingerprint image */
10705
+ if (bin .data == 0 || bin .c != SOD_IMG_GRAYSCALE ) {
10706
+ /* Must be a binary image processed via sod_hilditch_thin_image() */
10707
+ return sod_make_empty_image (0 , 0 , 0 );
10708
+ }
10709
+ sod_img out = sod_make_image (bin .w , bin .h , bin .c );
10710
+ if (out .data ) {
10711
+ int x , y ;
10712
+ int total , np1 , np2 ; /* number of black and minutiae points */
10713
+ int cross ;
10714
+ int i ;
10715
+ for (i = 0 ; i < out .w * out .h ; i ++ ) {
10716
+ if (bin .data [i ] == 1 ) {
10717
+ out .data [i ] = 200 ;
10718
+ }
10719
+ else {
10720
+ out .data [i ] = 1 ;
10721
+ }
10722
+ }
10723
+ /* finding minutiae in 3 x 3 window
10724
+ * Minutiae extraction is applied to skeletonized fingerprint.
10725
+ */
10726
+ total = 0 ;
10727
+ np1 = 0 ; /* number of ending points */
10728
+ np2 = 0 ; /* number of bifurcations */
10729
+ for (y = 1 ; y < bin .h - 1 ; y ++ ) {
10730
+ for (x = 1 ; x < bin .w - 1 ; x ++ ) {
10731
+ if (bin .data [y * bin .w + x ] == 0 ) {
10732
+ total ++ ;
10733
+ cross = minutiae_crossnumber (bin .data , y , x , bin .w );
10734
+ if (cross == 1 ) {
10735
+ np1 ++ ;
10736
+ out .data [y * bin .w + x ] = 0 ;
10737
+ }
10738
+ else if (cross >= 3 ) {
10739
+ np2 ++ ;
10740
+ out .data [y * bin .w + x ] = 0 ;
10741
+ }
10742
+ }
10743
+ }
10744
+ }
10745
+ if (pTotal ) {
10746
+ * pTotal = total ;
10747
+ }
10748
+ if (pEp ) {
10749
+ * pEp = np1 ;
10750
+ }
10751
+ if (pBp ) {
10752
+ * pBp = np2 ;
10753
+ }
10754
+ }
10755
+ return out ;
10756
+ }
10669
10757
/*
10670
10758
* Gaussian Noise Reduce on a grayscale image.
10671
10759
* apply 5x5 Gaussian convolution filter, shrinks the image by 4 pixels in each direction, using Gaussian filter found here:
@@ -13870,4 +13958,4 @@ void sod_img_save_to_cv_jpg(sod_img im, const char *zPath)
13870
13958
const char * sod_lib_copyright (void )
13871
13959
{
13872
13960
return SOD_LIB_INFO ;
13873
- }
13961
+ }
0 commit comments