Finite Difference Scheme for the Affine Morphological Scale Space. More...
#include <stdlib.h>
#include <tiffio.h>
#include <time.h>
#include <math.h>
#include "io_tiff_routine.h"
Go to the source code of this file.
Defines | |
#define | FATAL(MSG) |
#define | INFO(MSG) |
#define | DEBUG(MSG) |
Functions | |
static void | heat (float *ptr_out, float *ptr_in, size_t n_col, int i, int i_prev, int i_next, int j, int j_prev, int j_next, float dt) |
Computes one iteration of Heat Equation. | |
static void | amss (float *ptr_out, float *ptr_in, size_t n_row, size_t n_col, float dt, float t_g) |
Computes one iteration of the Affine Morphological Scale Space. | |
int | main (int argc, char *argv[]) |
main function call |
Finite Difference Scheme for the Affine Morphological Scale Space.
requirements:
compilation:
usage: this programs requires 3 arguments written in the following order,
The normalized scale represents the scale at which a circle with radius disappears. The number of iterations needed is linked to normalized scale and time step by the following formula:
where is the normalized scale, the time step and the number of iterations.
Definition in file FDS_AMSS.c.
#define DEBUG | ( | MSG | ) |
do {\ if (debug_flag)\ fprintf(stderr, __FILE__ ":%03i " MSG "\n", __LINE__);\ } while (0);
print a debug message, with detailed information
Definition at line 95 of file FDS_AMSS.c.
#define FATAL | ( | MSG | ) |
do {\ fprintf(stderr, MSG "\n");\ abort();\ } while (0);
print a message and abort the execution
Definition at line 82 of file FDS_AMSS.c.
#define INFO | ( | MSG | ) |
do {\ fprintf(stderr, MSG "\n");\ } while (0);
print an info message
Definition at line 89 of file FDS_AMSS.c.
static void amss | ( | float * | ptr_out, | |
float * | ptr_in, | |||
size_t | n_row, | |||
size_t | n_col, | |||
float | dt, | |||
float | t_g | |||
) | [static] |
Computes one iteration of the Affine Morphological Scale Space.
This function applies a Finite Difference Scheme for Affine Curvature Motion
Similarly to MCM, when , we denote by the direction orthogonal to and by the angle between the positive semiaxis and the gradient. Hence
and the continuous equation can be translated in this discrete version:
As regards the numerical evaluation of , we adopt a linear finite difference scheme based on a stencil.
which can be rewritten in a more synthetic form, using a discrete convolution with a variable kernel
We talk about since the depend on the direction of and can be calculated directly from the FDS of the partial derivatives and .
where we have denoted respectively by and the algebric sums at the numerator of and .
A very similar procedure is followed if we want to obtain an algorithm for MCM. The only difference is that for the Mean Curvature Motion we must discretize only , which can be seen again as the result of a convolution with a discrete kernel :
Thus the choice of the can be reduced to that of the , since for . Experiments have shown that if we take , i.e. the same value used in MCM, the best results as regards stability are achieved. Therefore the following formulas are actually adopted in the algorithm:
Remember that the array representing the image is examinated as a matrix, i.e. : is the current row number and is the current column number. The infinitezimal is the pixel width and is set to .
On the border, we symmetrize the image with respect to the axes and , i.e.
From a theorical point of view, even if we divide by the gradient, there is no need to apply Heat Equation when .
In fact and, if the Affine Morphological Scale Space is well defined. In addition even and consequently all the are well defined in the limit, since .
However rounding and approximation errors lead us to replace AMSS with Heat Equation when the gradient is below a threshold (experimentally set to for the first iteration and then reduced to for the next ones).
[out] | ptr_out | pointer to the output array |
[in] | ptr_in | pointer to the input array |
[in] | n_row | number of rows |
[in] | n_col | number of columns |
[in] | dt | time step |
[in] | t_g | threshold for the gradient |
Definition at line 301 of file FDS_AMSS.c.
static void heat | ( | float * | ptr_out, | |
float * | ptr_in, | |||
size_t | n_col, | |||
int | i, | |||
int | i_prev, | |||
int | i_next, | |||
int | j, | |||
int | j_prev, | |||
int | j_next, | |||
float | dt | |||
) | [static] |
Computes one iteration of Heat Equation.
This function applies the following Finite Difference Scheme for Heat Equation
where the discrete laplacian is given by
[out] | ptr_out | pointer to the output array |
[in] | ptr_in | pointer to the input array |
[in] | n_col | number of columns |
i | current row | |
i_prev | previous row | |
i_next | next row | |
j | current column | |
j_prev | previous column | |
j_next | next column | |
[in] | dt | time step |
Definition at line 135 of file FDS_AMSS.c.
int main | ( | int | argc, | |
char * | argv[] | |||
) |
main function call
The program reads an image.tiff given as input, applies a Finite Difference Scheme for the Affine Morphological Scale Space at renormalized scale , writes the result as a new image.tiff and returns it as output.
Definition at line 380 of file FDS_AMSS.c.