Commit 4e5cfdf9 authored by Daniel Drake's avatar Daniel Drake

NBIS cleanup

Part 1 of many. Remove some unused/pointless code, and made some code
static.
parent 6b8d17ef
......@@ -20,3 +20,4 @@ depcomp
install-sh
.deps
.libs
compile
......@@ -33,10 +33,8 @@ NBIS_SRC = \
nbis/mindtct/matchpat.c \
nbis/mindtct/minutia.c \
nbis/mindtct/morph.c \
nbis/mindtct/mytime.c \
nbis/mindtct/quality.c \
nbis/mindtct/remove.c \
nbis/mindtct/results.c \
nbis/mindtct/ridges.c \
nbis/mindtct/shape.c \
nbis/mindtct/sort.c \
......
......@@ -701,24 +701,15 @@ typedef struct lfsparms{
/*************************************************************************/
/* binar.c */
extern int binarize(unsigned char **, int *, int *,
unsigned char *, const int, const int,
int *, const int, const int,
const ROTGRIDS *, const LFSPARMS *);
extern int binarize_V2(unsigned char **, int *, int *,
unsigned char *, const int, const int,
int *, const int, const int,
const ROTGRIDS *, const LFSPARMS *);
extern int binarize_image(unsigned char **, int *, int *,
unsigned char *, const int, const int,
const int *, const int, const int, const int,
const ROTGRIDS *, const int);
extern int binarize_image_V2(unsigned char **, int *, int *,
unsigned char *, const int, const int,
const int *, const int, const int,
const int, const ROTGRIDS *);
extern int dirbinarize(const unsigned char *, const int, const ROTGRIDS *);
extern int isobinarize(unsigned char *, const int, const int, const int);
/* block.c */
extern int block_offsets(int **, int *, int *, const int, const int,
......@@ -763,12 +754,6 @@ extern void fix_edge_pixel_pair(int *, int *, int *, int *,
unsigned char *, const int, const int);
/* detect.c */
extern int lfs_detect_minutiae( MINUTIAE **,
int **, int **, int *, int *,
unsigned char **, int *, int *,
unsigned char *, const int, const int,
const LFSPARMS *);
extern int lfs_detect_minutiae_V2(MINUTIAE **,
int **, int **, int **, int **, int *, int *,
unsigned char **, int *, int *,
......@@ -779,13 +764,8 @@ extern int lfs_detect_minutiae_V2(MINUTIAE **,
extern int dft_dir_powers(double **, unsigned char *, const int,
const int, const int, const DFTWAVES *,
const ROTGRIDS *);
extern void sum_rot_block_rows(int *, const unsigned char *, const int *,
const int);
extern void dft_power(double *, const int *, const DFTWAVE *, const int);
extern int dft_power_stats(int *, double *, int *, double *, double **,
const int, const int, const int);
extern void get_max_norm(double *, int *, double *, const double *, const int);
extern int sort_dft_waves(int *, const double *, const double *, const int);
/* free.c */
extern void free_dir2rad(DIR2RAD *);
......@@ -818,7 +798,6 @@ extern int search_in_direction(int *, int *, int *, int *, const int,
/* init.c */
extern int init_dir2rad(DIR2RAD **, const int);
extern int init_dftwaves(DFTWAVES **, const double *, const int, const int);
extern int get_max_padding(const int, const int, const int, const int);
extern int get_max_padding_V2(const int, const int, const int, const int);
extern int init_rotgrids(ROTGRIDS **, const int, const int, const int,
const double, const int, const int, const int, const int);
......@@ -833,8 +812,6 @@ extern int is_qmap_empty(int *, const int, const int);
/* line.c */
extern int line_points(int **, int **, int *,
const int, const int, const int, const int);
extern int bresenham_line_points(int **, int **, int *,
const int, const int, const int, const int);
/* link.c */
extern int link_minutiae(MINUTIAE *, unsigned char *, const int, const int,
......@@ -872,16 +849,8 @@ extern int process_loop_V2(MINUTIAE *, const int *, const int *,
const int *, const int *, const int,
unsigned char *, const int, const int,
int *, const LFSPARMS *);
extern void get_loop_aspect(int *, int *, double *, int *, int *, double *,
const int *, const int *, const int);
extern int fill_loop(const int *, const int *, const int,
unsigned char *, const int, const int);
extern void fill_partial_row(const int, const int, const int, const int,
unsigned char *, const int, const int);
extern void flood_loop(const int *, const int *, const int,
unsigned char *, const int, const int);
extern void flood_fill4(const int, const int, const int,
unsigned char *, const int, const int);
/* maps.c */
extern int gen_image_maps(int **, int **, int **, int **, int *, int *,
......@@ -901,10 +870,6 @@ extern void smooth_direction_map(int *, int *, const int, const int,
const DIR2RAD *, const LFSPARMS *);
extern int gen_high_curve_map(int **, int *, const int, const int,
const LFSPARMS *);
extern int gen_imap(int **, int *, int *,
unsigned char *, const int, const int,
const DIR2RAD *, const DFTWAVES *, const ROTGRIDS *,
const LFSPARMS *);
extern int gen_initial_imap(int **, int *, const int, const int,
unsigned char *, const int, const int,
const DFTWAVES *, const ROTGRIDS *, const LFSPARMS *);
......@@ -935,7 +900,6 @@ extern void average_8nbr_dir(int *, double *, int *, int *, const int,
extern int num_valid_8nbrs(int *, const int, const int, const int, const int);
extern void smooth_imap(int *, const int, const int, const DIR2RAD *,
const LFSPARMS *);
extern int gen_nmap(int **, int *, const int, const int, const LFSPARMS *);
extern int vorticity(int *, const int, const int, const int, const int,
const int);
extern void accum_nbr_vorticity(int *, const int, const int, const int);
......@@ -954,9 +918,6 @@ extern void skip_repeated_vertical_pair(int *, const int,
/* minutia.c */
extern int alloc_minutiae(MINUTIAE **, const int);
extern int realloc_minutiae(MINUTIAE *, const int);
extern int detect_minutiae(MINUTIAE *, unsigned char *, const int, const int,
const int *, const int *, const int, const int,
const LFSPARMS *);
extern int detect_minutiae_V2(MINUTIAE *,
unsigned char *, const int, const int,
int *, int *, int *, const int, const int,
......@@ -1083,58 +1044,6 @@ extern int remove_false_minutia_V2(MINUTIAE *,
unsigned char *, const int, const int,
int *, int *, int *, const int, const int,
const LFSPARMS *);
extern int remove_holes(MINUTIAE *, unsigned char *, const int, const int,
const LFSPARMS *);
extern int remove_hooks(MINUTIAE *,
unsigned char *, const int, const int, const LFSPARMS *);
extern int remove_hooks_islands_lakes_overlaps(MINUTIAE *, unsigned char *,
const int, const int, const LFSPARMS *);
extern int remove_islands_and_lakes(MINUTIAE *,
unsigned char *, const int, const int, const LFSPARMS *);
extern int remove_malformations(MINUTIAE *,
unsigned char *, const int, const int,
int *, const int, const int, const LFSPARMS *);
extern int remove_near_invblock(MINUTIAE *, int *, const int, const int,
const LFSPARMS *);
extern int remove_near_invblock_V2(MINUTIAE *, int *,
const int, const int, const LFSPARMS *);
extern int remove_pointing_invblock(MINUTIAE *, int *, const int, const int,
const LFSPARMS *);
extern int remove_pointing_invblock_V2(MINUTIAE *,
int *, const int, const int, const LFSPARMS *);
extern int remove_overlaps(MINUTIAE *,
unsigned char *, const int, const int, const LFSPARMS *);
extern int remove_pores(MINUTIAE *,
unsigned char *, const int, const int,
int *, const int, const int, const LFSPARMS *);
extern int remove_pores_V2(MINUTIAE *,
unsigned char *, const int, const int,
int *, int *, int *, const int, const int,
const LFSPARMS *);
extern int remove_or_adjust_side_minutiae(MINUTIAE *, unsigned char *,
const int, const int, const LFSPARMS *);
extern int remove_or_adjust_side_minutiae_V2(MINUTIAE *,
unsigned char *, const int, const int,
int *, const int, const int, const LFSPARMS *);
/* results.c */
extern int write_text_results(char *, const int, const int, const int,
const MINUTIAE *, int *, int *, int *, int *, int *,
const int, const int);
extern int write_minutiae_XYTQ(char *ofile, const int,
const MINUTIAE *, const int, const int);
extern void dump_map(FILE *, int *, const int, const int);
extern int drawimap(int *, const int, const int, unsigned char *,
const int, const int, const ROTGRIDS *, const int);
extern void drawimap2(int *, const int *, const int, const int,
unsigned char *, const int, const int,
const double, const int, const int);
extern void drawblocks(const int *, const int, const int,
unsigned char *, const int, const int, const int );
extern int drawrotgrid(const ROTGRIDS *, const int, unsigned char *,
const int, const int, const int, const int);
extern void dump_link_table(FILE *, const int *, const int *, const int *,
const int, const int, const int, const MINUTIAE *);
/* ridges.c */
extern int count_minutiae_ridges(MINUTIAE *,
......@@ -1159,11 +1068,8 @@ extern int validate_ridge_crossing(const int, const int,
unsigned char *, const int, const int, const int);
/* shape.c */
extern int alloc_shape(SHAPE **, const int, const int, const int, const int);
extern void free_shape(SHAPE *);
extern void dump_shape(FILE *, const SHAPE *);
extern int shape_from_contour(SHAPE **, const int *, const int *, const int);
extern void sort_row_on_x(ROW *);
/* sort.c */
extern int sort_indices_int_inc(int **, int *, const int);
......
/*******************************************************************************
License:
This software was developed at the National Institute of Standards and
Technology (NIST) by employees of the Federal Government in the course
of their official duties. Pursuant to title 17 Section 105 of the
United States Code, this software is not subject to copyright protection
and is in the public domain. NIST assumes no responsibility whatsoever for
its use by other parties, and makes no guarantees, expressed or implied,
about its quality, reliability, or any other characteristic.
Disclaimer:
This software was developed to promote biometric standards and biometric
technology testing for the Federal Government in accordance with the USA
PATRIOT Act and the Enhanced Border Security and Visa Entry Reform Act.
Specific hardware and software products identified in this software were used
in order to perform the software development. In no case does such
identification imply recommendation or endorsement by the National Institute
of Standards and Technology, nor does it imply that the products and equipment
identified are necessarily the best available for the purpose.
*******************************************************************************/
#ifndef _MYTIME_H
#define _MYTIME_H
/* this file needed to support timer and ticks */
/* UPDATED: 03/16/2005 by MDG */
#ifdef TIMER
#include <sys/types.h>
#include <sys/times.h>
#endif
#ifdef TIMER
#define set_timer(_timer_); \
{ \
_timer_ = (unsigned long)ticks();
#else
#define set_timer(_timer_);
#endif
#ifdef TIMER
#define time_accum(_timer_, _var_); \
_var_ += ((unsigned long)ticks() - _timer_)/(float)ticksPerSec(); \
}
#else
#define time_accum(_timer_, _var_);
#endif
#ifdef TIMER
#define print_time(_fp_, _fmt_, _var_); \
fprintf(_fp_, _fmt_, _var_);
#else
#define print_time(_fp_, _fmt_, _var_);
#endif
extern unsigned long ticks(void);
extern int ticksPerSec(void);
extern unsigned long total_timer;
extern float total_time;
extern unsigned long imap_timer;
extern float imap_time;
extern unsigned long bin_timer;
extern float bin_time;
extern unsigned long minutia_timer;
extern float minutia_time;
extern unsigned long rm_minutia_timer;
extern float rm_minutia_time;
extern unsigned long ridge_count_timer;
extern float ridge_count_time;
#endif
......@@ -36,12 +36,9 @@ identified are necessarily the best available for the purpose.
***********************************************************************
ROUTINES:
binarize()
binarize_V2()
binarize_image()
binarize_image_V2()
dirbinarize()
isobinarize()
***********************************************************************/
......@@ -49,58 +46,6 @@ identified are necessarily the best available for the purpose.
#include <stdlib.h>
#include <lfs.h>
/*************************************************************************
**************************************************************************
#cat: binarize - Takes a padded grayscale input image and its associated ridge
#cat: direction flow NMAP and produces a binarized version of the
#cat: image. It then fills horizontal and vertical "holes" in the
#cat: binary image results.
Input:
pdata - padded input grayscale image
pw - padded width (in pixels) of input image
ph - padded height (in pixels) of input image
nmap - 2-D vector of IMAP directions and other codes
mw - width (in blocks) of the NMAP
mh - height (in blocks) of the NMAP
dirbingrids - set of rotated grid offsets used for directional
binarization
lfsparms - parameters and thresholds for controlling LFS
Output:
optr - points to created (unpadded) binary image
ow - width of binary image
oh - height of binary image
Return Code:
Zero - successful completion
Negative - system error
**************************************************************************/
int binarize(unsigned char **optr, int *ow, int *oh,
unsigned char *pdata, const int pw, const int ph,
int *nmap, const int mw, const int mh,
const ROTGRIDS *dirbingrids, const LFSPARMS *lfsparms)
{
unsigned char *bdata;
int i, bw, bh, ret; /* return code */
/* 1. Binarize the padded input image using NMAP information. */
if((ret = binarize_image(&bdata, &bw, &bh, pdata, pw, ph,
nmap, mw, mh, lfsparms->blocksize,
dirbingrids, lfsparms->isobin_grid_dim))){
return(ret);
}
/* 2. Fill black and white holes in binary image. */
/* LFS scans the binary image, filling holes, 3 times. */
for(i = 0; i < lfsparms->num_fill_holes; i++)
fill_holes(bdata, bw, bh);
/* Return binarized input image. */
*optr = bdata;
*ow = bw;
*oh = bh;
return(0);
}
/*************************************************************************
**************************************************************************
#cat: binarize_V2 - Takes a padded grayscale input image and its associated
......@@ -156,89 +101,6 @@ int binarize_V2(unsigned char **odata, int *ow, int *oh,
return(0);
}
/*************************************************************************
**************************************************************************
#cat: binarize_image - Takes a grayscale input image and its associated
#cat: NMAP and generates a binarized version of the image.
Input:
pdata - padded input grayscale image
pw - padded width (in pixels) of input image
ph - padded height (in pixels) of input image
nmap - 2-D vector of IMAP directions and other codes
mw - width (in blocks) of the NMAP
mh - height (in blocks) of the NMAP
imap_blocksize - dimension (in pixels) of each NMAP block
dirbingrids - set of rotated grid offsets used for directional
binarization
isobin_grid_dim - dimension (in pixels) of grid used for isotropic
binarization
Output:
optr - points to binary image results
ow - points to binary image width
oh - points to binary image height
Return Code:
Zero - successful completion
Negative - system error
**************************************************************************/
int binarize_image(unsigned char **optr, int *ow, int *oh,
unsigned char *pdata, const int pw, const int ph,
const int *nmap, const int mw, const int mh,
const int imap_blocksize, const ROTGRIDS *dirbingrids,
const int isobin_grid_dim)
{
int ix, iy, bw, bh, bx, by, nmapval;
unsigned char *bdata, *bptr;
unsigned char *pptr, *spptr;
/* Compute dimensions of "unpadded" binary image results. */
bw = pw - (dirbingrids->pad<<1);
bh = ph - (dirbingrids->pad<<1);
bdata = (unsigned char *)malloc(bw*bh*sizeof(unsigned char));
if(bdata == (unsigned char *)NULL){
fprintf(stderr, "ERROR : binarize_image : malloc : bdata\n");
return(-110);
}
bptr = bdata;
spptr = pdata + (dirbingrids->pad * pw) + dirbingrids->pad;
for(iy = 0; iy < bh; iy++){
/* Set pixel pointer to start of next row in grid. */
pptr = spptr;
for(ix = 0; ix < bw; ix++){
/* Compute which block the current pixel is in. */
bx = (int)(ix/imap_blocksize);
by = (int)(iy/imap_blocksize);
/* Get corresponding value in NMAP */
nmapval = *(nmap + (by*mw) + bx);
/* If current block has no neighboring blocks with */
/* VALID directions ... */
if(nmapval == NO_VALID_NBRS)
/* Set binary pixel to white (255). */
*bptr = WHITE_PIXEL;
/* Otherwise, if block's NMAP has a valid direction ... */
else if(nmapval >= 0)
/* Use directional binarization based on NMAP direction. */
*bptr = dirbinarize(pptr, nmapval, dirbingrids);
else
/* Otherwise, the block's NMAP is either INVALID or */
/* HIGH-CURVATURE, so use isotropic binarization. */
*bptr = isobinarize(pptr, pw, ph, isobin_grid_dim);
/* Bump input and output pixel pointers. */
pptr++;
bptr++;
}
/* Bump pointer to the next row in padded input image. */
spptr += pw;
}
*optr = bdata;
*ow = bw;
*oh = bh;
return(0);
}
/*************************************************************************
**************************************************************************
#cat: binarize_image_V2 - Takes a grayscale input image and its associated
......@@ -385,71 +247,3 @@ int dirbinarize(const unsigned char *pptr, const int idir,
return(WHITE_PIXEL);
}
/*************************************************************************
**************************************************************************
#cat: isobinarize - Determines the binary value of a grayscale pixel based
#cat: on comparing the grayscale value with a surrounding
#cat: neighborhood grid of pixels. If the current pixel (treated
#cat: as an average) is less than the sum of the pixels in
#cat: the neighborhood, then the binary value is set to BLACK,
#cat: otherwise it is set to WHITE. This binarization technique
#cat: is used when there is no VALID IMAP direction for the
#cat: block in which the current pixel resides.
CAUTION: The image to which the input pixel points must be appropriately
padded to account for the radius of the neighborhood. Otherwise,
this routine may access "unkown" memory.
Input:
pptr - pointer to curent grayscale pixel
pw - padded width (in pixels) of the grayscale image
ph - padded height (in pixels) of the grayscale image
isobin_grid_dim - dimension (in pixels) of the neighborhood
Return Code:
BLACK_PIXEL - pixel intensity for BLACK
WHITE_PIXEL - pixel intensity of WHITE
**************************************************************************/
int isobinarize(unsigned char *pptr, const int pw, const int ph,
const int isobin_grid_dim)
{
unsigned char *sptr, *cptr;
int px, py;
int radius;
int bsum;
double drad;
/* Initialize grid pixel sum to zero. */
bsum = 0;
/* Compute radius from current pixel based on isobin_grid_dim. */
drad = (isobin_grid_dim - 1)/(double)2.0;
/* Need to truncate precision so that answers are consistent */
/* on different computer architectures when rounding doubles. */
drad = trunc_dbl_precision(drad, TRUNC_SCALE);
radius = sround(drad);
/* Set pointer to origin of grid centered on the current pixel. */
sptr = pptr - (radius*pw) - radius;
/* For each row in the grid ... */
for(py = 0; py < isobin_grid_dim; py++){
/* Set pixel pointer to start of next row in grid. */
cptr = sptr;
/* For each column in the grid ... */
for(px = 0; px < isobin_grid_dim; px++){
/* Accumulate next pixel in the grid. */
bsum += *cptr;
/* Bump pixel pointer. */
cptr++;
}
/* Bump to the start of the next row in the grid. */
sptr += pw;
}
/* If current (center) pixel when treated as an average for the */
/* entire grid is less than the total pixel sum of the grid ... */
if((*pptr * isobin_grid_dim * isobin_grid_dim) < bsum)
/* Set the binary pixel to BLACK. */
return(BLACK_PIXEL);
else
/* Otherwise, set the binary pixel to WHITE. */
return(WHITE_PIXEL);
}
This diff is collapsed.
This diff is collapsed.
......@@ -37,7 +37,6 @@ identified are necessarily the best available for the purpose.
ROUTINES:
init_dir2rad()
init_dftwaves()
get_max_padding()
get_max_padding_V2()
init_rotgrids()
alloc_dir_powers()
......@@ -243,80 +242,6 @@ int init_dftwaves(DFTWAVES **optr, const double *dft_coefs,
return(0);
}
/*************************************************************************
**************************************************************************
#cat: get_max_padding - Deterines the maximum amount of image pixel padding
#cat: required by all LFS processes. Padding is currently
#cat: required by the rotated grids used in DFT analyses,
#cat: rotated grids used in directional binarization,
#cat: and in the grid used for isotropic binarization.
#cat: The NIST generalized code enables the parameters
#cat: governing these processes to be redefined, so a check
#cat: at runtime is required to determine which process
#cat: requires the most padding. By using the maximum as
#cat: the padding factor, all processes will run safely
#cat: with a single padding of the input image avoiding the
#cat: need to repad for further processes.
Input:
imap_blocksize - the size (in pixels) of each IMAP block in the image
dirbin_grid_w - the width (in pixels) of the rotated grids used in
directional binarization
dirbin_grid_h - the height (in pixels) of the rotated grids used in
directional binarization
isobin_grid_dim - the dimension (in pixels) of the square grid used in
isotropic binarization
Return Code:
Non-negative - the maximum padding required for all processes
**************************************************************************/
int get_max_padding(const int imap_blocksize,
const int dirbin_grid_w, const int dirbin_grid_h,
const int isobin_grid_dim)
{
int dft_pad, dirbin_pad, isobin_pad, max_pad;
double diag;
double pad;
/* Compute pad required for rotated blocks used in DFT analyses. */
diag = sqrt((double)(2.0 * imap_blocksize * imap_blocksize));
/* Compute pad as difference between the IMAP blocksize */
/* and the diagonal distance of the block. */
/* Assumption: all block origins reside in valid/allocated memory. */
/* DFT grids are computed with pixel offsets RELATIVE2ORIGIN. */
pad = (diag-imap_blocksize)/(double)2.0;
/* Need to truncate precision so that answers are consistent */
/* on different computer architectures when rounding doubles. */
pad = trunc_dbl_precision(pad, TRUNC_SCALE);
dft_pad = sround(pad);
/* Compute pad required for rotated blocks used in directional */
/* binarization. */
diag = sqrt((double)((dirbin_grid_w*dirbin_grid_w)+
(dirbin_grid_h*dirbin_grid_h)));
/* Assumption: all grid centers reside in valid/allocated memory. */
/* dirbin grids are computed with pixel offsets RELATIVE2CENTER. */
pad = (diag-1)/(double)2.0;
/* Need to truncate precision so that answers are consistent */
/* on different computer architectures when rounding doubles. */
pad = trunc_dbl_precision(pad, TRUNC_SCALE);
dirbin_pad = sround(pad);
/* Compute pad required for grids used in isotropic binarization. */
pad = (isobin_grid_dim - 1)/(double)2.0;
/* Need to truncate precision so that answers are consistent */
/* on different computer architectures when rounding doubles. */
pad = trunc_dbl_precision(pad, TRUNC_SCALE);
isobin_pad = sround((isobin_grid_dim - 1)/(double)2.0);
max_pad = max(dft_pad, dirbin_pad);
max_pad = max(max_pad, isobin_pad);
/* Return the maximum of the three required paddings. This padding will */
/* be sufficiently large for all three purposes, so that padding of the */
/* input image will only be required once. */
return(max_pad);
}
/*************************************************************************
**************************************************************************
#cat: get_max_padding_V2 - Deterines the maximum amount of image pixel padding
......
This diff is collapsed.
......@@ -46,7 +46,6 @@ identified are necessarily the best available for the purpose.
pixelize_map()
smooth_direction_map()
gen_high_curve_map()
gen_imap()
gen_initial_imap()
primary_dir_test()
secondary_fork_test()
......@@ -59,7 +58,6 @@ identified are necessarily the best available for the purpose.
average_8nbr_dir()
num_valid_8nbrs()
smooth_imap()
gen_nmap()
vorticity()
accum_nbr_vorticity()
curvature()
......@@ -930,75 +928,6 @@ int gen_high_curve_map(int **ohcmap, int *direction_map,
return(0);
}
/*************************************************************************
**************************************************************************
#cat: gen_imap - Computes an IMAP, which is a 2D vector of integer directions,
#cat: where each direction represents the dominant ridge flow in
#cat: a block of the input grayscale image. This routine will
#cat: generate an IMAP for arbitrarily sized, non-square, images.
Input:
pdata - padded input image data (8 bits [0..256) grayscale)
pw - padded width (in pixels) of the input image
ph - padded height (in pixels) of the input image
dir2rad - lookup table for converting integer directions
dftwaves - structure containing the DFT wave forms
dftgrids - structure containing the rotated pixel grid offsets
lfsparms - parameters and thresholds for controlling LFS
Output:
optr - points to the created IMAP
ow - width (in blocks) of the IMAP
oh - height (in blocks) of the IMAP
Return Code:
Zero - successful completion
Negative - system error
**************************************************************************/
int gen_imap(int **optr, int *ow, int *oh,
unsigned char *pdata, const int pw, const int ph,
const DIR2RAD *dir2rad, const DFTWAVES *dftwaves,
const ROTGRIDS *dftgrids, const LFSPARMS *lfsparms)
{
int *imap, mw, mh, iw, ih;
int *blkoffs;
int ret; /* return code */
/* 1. Compute block offsets for the entire image, accounting for pad */
/* Block_offsets() assumes square block (grid), so ERROR otherwise. */
if(dftgrids->grid_w != dftgrids->grid_h){
fprintf(stderr, "ERROR : gen_imap : DFT grids must be square\n");
return(-60);
}
/* Compute unpadded image dimensions. */
iw = pw - (dftgrids->pad<<1);
ih = ph - (dftgrids->pad<<1);
if((ret = block_offsets(&blkoffs, &mw, &mh, iw, ih,
dftgrids->pad, dftgrids->grid_w))){
return(ret);
}
/* 2. Generate initial imap */
if((ret = gen_initial_imap(&imap, blkoffs, mw, mh, pdata, pw, ph,
dftwaves, dftgrids, lfsparms))){
/* Free memory allocated to this point. */
free(blkoffs);
return(ret);
}
/* 3. Remove IMAP directions that are inconsistent with neighbors */
remove_incon_dirs(imap, mw, mh, dir2rad, lfsparms);
/* 4. Smooth imap values with their neighbors */
smooth_imap(imap, mw, mh, dir2rad, lfsparms);
/* Deallocate working memory. */
free(blkoffs);
*optr = imap;
*ow = mw;
*oh = mh;
return(0);
}
/*************************************************************************
**************************************************************************
#cat: gen_initial_imap - Creates an initial IMAP from the given input image.
......@@ -2160,100 +2089,6 @@ void smooth_imap(int *imap, const int mw, const int mh,
}
}
/*************************************************************************
**************************************************************************
#cat: gen_nmap - Computes an NMAP from its associated 2D vector of integer
#cat: directions (IMAP). Each value in the NMAP either represents
#cat: a direction of dominant ridge flow in a block of the input
#cat: grayscale image, or it contains a codes describing why such
#cat: a direction was not procuded.
#cat: For example, blocks near areas of high-curvature (such as
#cat: with cores and deltas) will not produce reliable IMAP
#cat: directions.
Input:
imap - associated input vector of IMAP directions
mw - the width (in blocks) of the IMAP
mh - the height (in blocks) of the IMAP
lfsparms - parameters and thresholds for controlling LFS
Output:
optr - points to the created NMAP