#ifndef pz_image_H #define pz_image_H /* Tools for image processing */ /* Last edited on 2017-06-20 21:04:28 by stolfilocal */ #include #include #include typedef enum { pz_side_inner, pz_side_interpolated, pz_side_outer } pz_side_t; typedef uint16_image_t pz_image_t; pz_image_t *pz_image_read_pgm (char *fName); /* Reads a PGM file {fName} and returns the image */ void pz_image_write_pgm (char *fName, pz_image_t *img); /* Writes the image {img} as file {fName}, in PGM format. */ r3_vec_t pz_image_extract_boundary ( pz_image_t *img, uint16_t maxbg, pz_side_t side ); /* Given a PGM image {img} of an object, returns a polygon with {Z=0} that approximates the object's outline, in the counterclockwise direction.. For this procedure, a pixel {(x,y)} is `inside the object' if {img[y,x] > maxbg}, and `outside' if {img[y,x] <= maxbg}. The {side} parameter selects between the inner, outer, and interpolated outlines. The first two have integer points {(x,y)} where {img[y,x] > maxbg} or {img[y,x] <= maxbg}, respectively. The interpolated outline lies between the two; it traces the level curve {img[x,y] == maxbg + 0.5} with subpixel accurancy. The procedure assumes that the pixels along the four edges of {img} are outside the object. */ /* Copyright © 2001 Universidade Estadual de Campinas (UNICAMP). Authors: Helena C. G. Leitão and Jorge Stolfi. This file can be freely distributed, used, and modified, provided that this copyright and authorship notice is preserved, and that any modified versions are clearly marked as such. This software has NO WARRANTY of correctness or applicability for any purpose. Neither the authors nor their employers chall be held responsible for any losses or damages that may result from its use. */ #endif