Functions

src/imageproc.c File Reference

#include "imageproc.h"
#include "linalg.h"

Go to the source code of this file.

Functions

Arraybresenham_line (int start[2], int end[2])
 Bresenhams Line-drawing-algorithm.
Arraybresenham_linesegments (const Array *points)
 Connected line-segments with bresenhams Line-drawing-algorithm.
Arraydisttransform_deadreckoning (const Array *in, Array *dt)
 calculate the (signed) distance-transform of a binary image.

Function Documentation

Array* bresenham_line ( int  start[2],
int  end[2] 
)

Bresenhams Line-drawing-algorithm.

(stolen and modified from Wikipedia)

Parameters:
start coordinates of starting point
end coordinates of last point
Returns:
a pointer to the line saved in pairs (x,y) of the coordinates (2 x N INT-Array);

Definition at line 237 of file imageproc.c.

Array* bresenham_linesegments ( const Array points  ) 

Connected line-segments with bresenhams Line-drawing-algorithm.

Calls bresenham_line() for each pair of points.

Example:

bresenham_segments.jpg
Parameters:
points 2xM INT-array containig coordinates points through which the line-segments should lead
Returns:
a pointer to the line saved in pairs (x,y) of the coordinates (2 x N INT-Array);

Definition at line 197 of file imageproc.c.

Array* disttransform_deadreckoning ( const Array in,
Array dt 
)

calculate the (signed) distance-transform of a binary image.

This distance-transform (DT) of a binary image includes at each pixel the shortest distance to the closest nonzero point in the input image.

Example (left is the binary matrix, right the DT; in the upper right corner is another white pixel):

disttransform.jpg

This implementation uses the dead-reckoning algorithm from

	 @article{grevera2004dead,
  	   title={{The" Dead reckoning" signed distance transform}},
	   author={Grevera, G.J.},
	   journal={Computer Vision and Image Understanding},
	   volume={95},
	   number={3},
	   pages={317--333},
	   year={2004}
	 }
	 
Parameters:
in INT-array representing a binary image
dt DOUBLE-array of same dimensions as in, or NULL (alloc in function)
Returns:
ptr to the distance transform of in

Definition at line 51 of file imageproc.c.