Commit 23872a33 authored by Martin Horauer's avatar Martin Horauer
Browse files

minor changes to README.adoc

parent f3724b00
------------------------------------------------------------------------
Beschreibung zur Fingerprintverificationsoftware
------------------------------------------------------------------------
Files:
-----------
fvs_main.c
Main funktion.
import.c, export.c
Importiert und exportiert unter anderem Bitmapimages
image.c, floatfield.c, minutia.c
Containerklassen + Basisfunktionen für Fingerprintimages, Floatfields
(z.B. für Winkelfelder) und Minutia.
img_base.c
Basisfuntionen zur Bearbeitung der Fingerprints wie z.B. Binarization,
Invertierung, Logische operationen zw. 2 Bildern, usw.
imagemanip.c
Erweiterte Funktionen zur Bildbearbeitung, wie z.B. Winkelberechnung,
Frequenzberechnung, Maskenberechnung oder Thinning-Funktionen.
imageenhance.c
Funktionen zur verbesserung der Bildqualität. Diese sind der aus
Performancegründen eingesparte Gabor Filter und der von uns entwickelte
Enhance_Thinning Algorithmus.
matching.c
Funktionen zum Vergleich zweier Minutiasets.
include/*.h
sämtliche Includefiles mit Beschreibungen zu den einzelnen Funktionen
Build:
--------------
make - baut eine Shared Library
Extrahieren der Minutien aus einem Fingerabruck:
--------------
Benötigte Bildobjekte: Maske, Fingerabruck
01. Bild Importieren
02. Filtern (Soften Mean) - Empfohlene Filterkernelgröße 3
03. Pixel Normalisieren - Empfohlene Filterkernelgröße 9
04. Canvas hinzufügen - Generiert Maske fixer Größe um die unbrauchbaren Seitenränder aus zu blenden. - Empfohlene Dicke 6
05. Berechnen der "Ridge" Direction - Empfohlene Parameter: 5 und 4
06. Logische Unverknüpfung von Bild und Maske
07. FFT von Bild berechnen.
08. Bild Gaborfiltern - Empfohlener Parameter: 4.0
09. Schwarz/Weiss Bild erzeugen
10. Ridges auf Linien breite von einem Pixel verkleinern (Thinning)
11. Erweiteretes Thinning
12. Extrahieren von Minutien
......@@ -72,8 +72,8 @@ Implement the above steps in a file `fvs_main.c`. To build, test and run the
final application you will need to link against the shared library.
....
gcc -Wall -Wextra --pedantic -lfvs fvs_main.c -o fvs
./fvs img/*.bmp
gcc -Wall -Wextra --pedantic -lfvs -L. -I./include fvs_main.c -o fvs
./fvs ../fvs_data_base/1_1.bmp
....
......
/*########################################################################
The contents of this file are subject to the Mozilla Public License
Version 1.0(the "License"); You may NOT use this file except in
compliance with the License. You may obtain a copy of the License at
http:// www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
The Initial Developer of the Original Code is Shivang Patel.
Copyright(C) 2002. All Rights Reserved.
Authors: Shivang Patel
Jaap de Haan(jdh)
Matthias Wenzl (mw)
Changes: jdh -> Added support for ImageMagick that enables
to export files to more than 40 formats.
mw -> Removed deprecated.
########################################################################*/
#include "import.h"
#include <stdio.h>
#include <string.h>
#include <magick/api.h>
/* imports a fingeprint image from a file */
FvsError_t FvsImageExport(const FvsImage_t image, const FvsString_t filename)
{
ExceptionInfo exception;
Image* magicimage;
ImageInfo* magicinfo;
FvsError_t ret = FvsOK;
FvsByte_t* buffer;
FvsInt_t pitch;
FvsInt_t height;
FvsInt_t width;
FvsInt_t i;
/* get buffer, size and pitch from the input image */
buffer = ImageGetBuffer(image);
pitch = ImageGetPitch(image);
height = ImageGetHeight(image);
width = ImageGetWidth(image);
/* Init Magick environment */
MagickCoreGenesis(".",MagickFalse);
//InitializeMagick(".");
GetExceptionInfo(&exception);
/* Create an empty imageinfo */
magicinfo = CloneImageInfo((ImageInfo*)NULL);
magicinfo->depth = 8;
/* create image */
magicimage = ConstituteImage(width, height, "I", CharPixel, buffer, &exception);
if (exception.severity!=UndefinedException)
CatchException(&exception);
if (magicimage!=(Image*)NULL)
{
/* copy the data */
for (i=0; i<height; i++)
{
ImportImagePixels(magicimage, 0, i, width, 1, "I", CharPixel,
buffer+i*pitch);
}
/* save the image to file */
(void)strcpy(magicimage->filename, filename);
magicimage->colorspace = GRAYColorspace;
magicimage->depth = 8;
WriteImage(magicinfo, magicimage);
/* dump info for debugging purposes */
/* DescribeImage(magicimage, stdout, 0); */
DestroyImage(magicimage);
}
else
ret = FvsFailure;
/* do cleanup */
DestroyImageInfo(magicinfo);
DestroyExceptionInfo(&exception);
MagickCoreTerminus();
//DestroyMagick();
return ret;
}
#if 0
/* The WAND interface is pretty buggy... use the old API */
/* exports a fingeprint image to a file */
FvsError_t FvsImageExport(const FvsImage_t image, const FvsString_t filename)
{
MagickWand* wand;
FvsByte_t* buffer;
FvsByte_t* out;
FvsInt_t pitch;
FvsInt_t height;
FvsInt_t width;
FvsError_t ret = FvsOK;
FvsInt_t i;
/* Init Magick */
wand = NewMagickWand();
if (wand!=NULL)
{
/* extract parameters */
buffer = ImageGetBuffer(image);
width = ImageGetWidth(image);
height = ImageGetHeight(image);
pitch = ImageGetPitch(image);
/* allocate a new buffer for the pixel data */
out = (FvsByte_t*)malloc(width*height);
if (out!=NULL)
{
for (i=0; i<height; i++)
memcpy(out+i*width, buffer+i*pitch, width);
/* out now contains the picture data in a contiguous buffer */
MagickSetSize(wand, width, height);
MagickSetImagePixels(wand, 0, 0, width, height, "I", CharPixel, out);
/* write data */
MagickWriteImage(wand, filename);
free(out);
}
else
ret = FvsMemory;
/* do cleanup */
DestroyMagickWand(wand);
}
else
ret = FvsMemory;
return ret;
}
#endif
/*########################################################################
*
* Copyright(C) 2002-2007. All Rights Reserved.
*
* Authors: Shivang Patel
* Jaap de Haan(jdh)
*
* Changes: jdh -> Added support for ImageMagick that enables
* to export files to more than 40 formats.
* This is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2, or (at your option) any later
* version.
*
* This is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License with
* the fvs source package as the
* file COPYING. If not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
########################################################################*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "floatfield.h"
/*!
A fingerprint floating point field structure.
*/
typedef struct iFvsFloatField_t
{
FvsFloat_t *pimg; /* floating point field array */
FvsInt_t w; /* width of field */
FvsInt_t h; /* height of field */
FvsInt_t pitch; /* pitch */
} iFvsFloatField_t;
FvsFloatField_t FloatFieldCreate()
{
iFvsFloatField_t* p = NULL;
p = (FvsFloatField_t)malloc(sizeof(iFvsFloatField_t));
if (p!=NULL)
{
p->h = 0;
p->w = 0;
p->pitch = 0;
p->pimg = NULL;
}
return (FvsFloatField_t)p;
}
void FloatFieldDestroy(FvsFloatField_t field)
{
iFvsFloatField_t* p = NULL;
if (field==NULL)
return;
p = field;
(void)FloatFieldSetSize(field, 0, 0);
free(p);
}
FvsError_t FloatFieldSetSize(FvsFloatField_t img, const FvsInt_t width, const FvsInt_t height)
{
iFvsFloatField_t* field = (iFvsFloatField_t*)img;
FvsError_t nRet = FvsOK;
FvsInt_t newsize = (FvsInt_t)(width*height*sizeof(FvsFloat_t));
/* special case for zero size */
if (newsize==0)
{
if (field->pimg!=NULL)
{
free(field->pimg);
field->pimg = NULL;
field->w = 0;
field->h = 0;
field->pitch = 0;
}
return FvsOK;
}
if ((FvsInt_t)(field->h*field->w*sizeof(FvsFloat_t)) != newsize)
{
free(field->pimg);
field->w = 0;
field->h = 0;
field->pitch = 0;
/* This allocates the amount of memory need for the field structure */
field->pimg = (FvsFloat_t*)malloc((size_t)newsize);
}
if (field->pimg == NULL)
nRet = FvsMemory;
else
{
field->h = height;
field->w = width;
field->pitch = width;
}
return nRet;
}
FvsError_t FloatFieldCopy(FvsFloatField_t destination, const FvsFloatField_t source)
{
iFvsFloatField_t* dest = (iFvsFloatField_t*)destination;
iFvsFloatField_t* src = (iFvsFloatField_t*)source;
FvsError_t nRet = FvsOK;
nRet = FloatFieldSetSize(dest, src->w, src->h);
if (nRet==FvsOK)
memcpy(dest->pimg, src->pimg, src->h*src->w*sizeof(FvsFloat_t));
return nRet;
}
FvsError_t FloatFieldClear(FvsFloatField_t img)
{
return FloatFieldFlood(img, 0.0);
}
FvsError_t FloatFieldFlood(FvsFloatField_t img, const FvsFloat_t value)
{
iFvsFloatField_t* field = (iFvsFloatField_t*)img;
FvsError_t nRet = FvsOK;
FvsInt_t i;
if (field->pimg!=NULL)
{
for (i=0; i<field->h*field->w; i++)
field->pimg[i] = value;
}
return nRet;
}
/* set a pixel value in the picture */
void FloatFieldSetValue(FvsFloatField_t img, const FvsInt_t x, const FvsInt_t y, const FvsFloat_t val)
{
iFvsFloatField_t* field = (iFvsFloatField_t*)img;
int address = y * field->w + x;
field->pimg[address] = val;
}
/* This function returns the pixel for the x and y value */
FvsFloat_t FloatFieldGetValue(FvsFloatField_t img, const FvsInt_t x, const FvsInt_t y)
{
iFvsFloatField_t* field = (iFvsFloatField_t*)img;
/* position in array */
int address = y * field->pitch + x;
return field->pimg[address];
}
/* returns a pointer to the field buffer */
FvsFloat_t* FloatFieldGetBuffer(FvsFloatField_t img)
{
iFvsFloatField_t* field = (iFvsFloatField_t*)img;
return field->pimg;
}
/* retrieve width and height */
FvsInt_t FloatFieldGetWidth(const FvsFloatField_t img)
{
iFvsFloatField_t* field = (iFvsFloatField_t*)img;
return field->w;
}
FvsInt_t FloatFieldGetHeight(const FvsFloatField_t img)
{
iFvsFloatField_t* field = (iFvsFloatField_t*)img;
return field->h;
}
/* get the pitch pixel(x,y) pos is at x + y * pitch */
FvsInt_t FloatFieldGetPitch(const FvsFloatField_t img)
{
iFvsFloatField_t* field = (iFvsFloatField_t*)img;
return field->pitch;
}
/*########################################################################
*
* Copyright(C) 2002-2007. All Rights Reserved.
*
* Authors: Shivang Patel
* Jaap de Haan(jdh)
*
* Changes: jdh -> Added support for ImageMagick that enables
* to export files to more than 40 formats.
* This is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2, or (at your option) any later
* version.
*
* This is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License with
* the fvs source package as the
* file COPYING. If not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
########################################################################*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "image.h"
/*!
A fingerprint image structure, a fingerprint image is a 256 gray level
image. This should be enough to do accurate processing. This image
class defines a common format for all algorithms running in this
suite. Images may be imported from different sources such as files,
network data, databases,...
*/
typedef struct iFvsImage_t
{
FvsByte_t *pimg; /* 8 bit image array */
FvsInt_t w; /* width of image */
FvsInt_t h; /* height of image */
FvsInt_t pitch; /* pitch */
FvsImageFlag_t flags; /* flags */
FvsInt_t dpi; /* dots per inch */
} iFvsImage_t;
FvsImage_t ImageCreate()
{
iFvsImage_t* p = NULL;
p = (FvsImage_t)malloc(sizeof(iFvsImage_t));
if (p!=NULL)
{
p->h = 0;
p->w = 0;
p->pitch = 0;
p->pimg = NULL;
p->flags = FvsImageGray; /* default flag */
}
return (FvsImage_t)p;
}
void ImageDestroy(FvsImage_t image)
{
iFvsImage_t* p = NULL;
if (image==NULL)
return;
(void)ImageSetSize(image, 0, 0);
p = image;
free(p);
}
FvsError_t ImageSetFlag(FvsImage_t img, const FvsImageFlag_t flag)
{
iFvsImage_t* image = (iFvsImage_t*)img;
image->flags = flag;
return FvsOK;
}
FvsError_t ImageSetDPI(FvsImage_t img, const FvsInt_t dpi)
{
iFvsImage_t* image = (iFvsImage_t*)img;
image->dpi = dpi;
return FvsOK;
}
FvsInt_t ImageGetDPI(const FvsImage_t img)
{
iFvsImage_t* image = (iFvsImage_t*)img;
return image->dpi;
}
FvsImageFlag_t ImageGetFlag(const FvsImage_t img)
{
iFvsImage_t* image = (iFvsImage_t*)img;
return image->flags;
}
FvsError_t ImageSetSize(FvsImage_t img, const FvsInt_t width, const FvsInt_t height)
{
iFvsImage_t* image = (iFvsImage_t*)img;
FvsError_t nRet = FvsOK;
FvsInt_t newsize = width*height;
/* special case for zero size */
if (newsize==0)
{
if (image->pimg!=NULL)
{
free(image->pimg);
image->pimg = NULL;
image->w = 0;
image->h = 0;
image->pitch = 0;
}
return FvsOK;
}
if (image->h*image->w != newsize)
{
free(image->pimg);
image->w = 0;
image->h = 0;
image->pitch = 0;
/* This allocates the amount of memory need for the image structure */
image->pimg = (uint8_t*)malloc((size_t)newsize);
}
if (image->pimg == NULL)
nRet = FvsMemory;
else
{
image->h = height;
image->w = width;
image->pitch = width;
}
return nRet;
}
FvsError_t ImageCopy(FvsImage_t destination, const FvsImage_t source)
{
iFvsImage_t* dest = (iFvsImage_t*)destination;
iFvsImage_t* src = (iFvsImage_t*)source;
FvsError_t nRet = FvsOK;
nRet = ImageSetSize(dest, src->w, src->h);
if (nRet==FvsOK)
memcpy(dest->pimg, src->pimg, (size_t)src->h*src->w);
/* copy the flag */
dest->flags = src->flags;
return nRet;
}
FvsError_t ImageClear(FvsImage_t img)
{
return ImageFlood(img, 0);
}
FvsError_t ImageFlood(FvsImage_t img, const FvsByte_t value)
{
FvsError_t nRet = FvsOK;
iFvsImage_t* image = (iFvsImage_t*)img;
if (image==NULL) return FvsMemory;
if (image->pimg!=NULL)
memset(image->pimg, (int)value, (size_t)(image->h*image->w));
return nRet;
}
/* set a pixel value in the picture */
void ImageSetPixel(FvsImage_t img, const FvsInt_t x, const FvsInt_t y, const FvsByte_t val)
{
iFvsImage_t* image = (iFvsImage_t*)img;
int address = y * image->w + x;
image->pimg[address] = val;
}
/* This function returns the pixel for the x and y value */
FvsByte_t ImageGetPixel(const FvsImage_t img, const FvsInt_t x, const FvsInt_t y)
{
iFvsImage_t* image = (iFvsImage_t*)img;
/* position in array */
int address = y * image->pitch + x;
return image->pimg[address];
}
/* returns a pointer to the image buffer */
FvsByte_t* ImageGetBuffer(FvsImage_t img)
{
iFvsImage_t* image = (iFvsImage_t*)img;
if (image==NULL) return NULL;
return image->pimg;
}
/* retrieve width and height */
FvsInt_t ImageGetWidth(const FvsImage_t img)
{
iFvsImage_t* image = (iFvsImage_t*)img;
if (image==NULL) return -1;