INTERFACE PZImage; (* Tools for image processing *) (* Last edited on 1999-08-06 22:11:44 by hcgl *) IMPORT PZLR3Chain; FROM PZTypes IMPORT NAT; TYPE GrayLevel = BITS 8 FOR [0..255]; T = ARRAY OF ARRAY OF GrayLevel; PROCEDURE ReadPGM(fName: TEXT): REF T; (* Reads a PGM file "fName" and returns the image *) PROCEDURE WritePGM(fName :TEXT; READONLY M: T); (* Writes the image "M" as file "fName", in PGM format. *) TYPE Side = {Inner, Interpolated, Outer}; PROCEDURE ExtractBoundary( READONLY M: T; black: NAT; grey: NAT; side: Side := Side.Interpolated; ): REF PZLR3Chain.T; (* Given a PGM image "M" of a single 4-connected puzzle piece, returns the piece's outline as a 2D closed curve. Assumes that "M[y,x] <= black" if and only if pixel "(x,y)" is outside the piece. The result traces the level curve "M[x,y] = grey" with subpixel accurancy, except that it will not deviate more than two pixels from the "M[x,y] = black" curve. Also assumes that the piece does not touch the boundary of "M". The "side" parameter specifies which contour to return. The "Inner" and "outer" contours have integer vertices. *) END PZImage. (* 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. *)