(* Last edited on 1999-03-14 12:23:52 by stolfi *) INTERFACE LineOps; (* Image operators for line detection. *) (* The ``line indicator'' operator is computed from a 3x3 window of the input. First, the pixels in the window are normalized so that the maximum is 1 and the minimum is 0. (If they are all equal, this step makes them all 0.5). Then, for each of the 8 peripheral pixels "p[i]", we compute the ``bump'' indicators "s[i] = p[i-1]*(1-p[i])*p[i+1]" We also shift the pixels by 1/2 pixel clockwise, obtaining pixels "q[0]" through "q[7]", and compute the same ``bump'' indicators from them: "t[i] = q[i-1]*(1-q[i])*q[i+1]" All indices here are modulo 8. Next we compute a MAX-like combination of these indicators, namely "h = 1 - (PROD{ 1 - s[i] : i }*PROD { 1 - t[i] : i })^(1/16)" where "alpha" and "beta" are user-given parameters. Finally, the value "h" is multiplied by the complement of the center pixel "c" to produce the result. *) IMPORT Interval3x3Window, PGMImageFilter; TYPE Interval = PGMImageFilter.Interval; Surround = ARRAY [0..7] OF Interval; LONG = LONGREAL; BOOL = BOOLEAN; PROCEDURE GetSurround( READONLY b: Interval3x3Window.T; VAR c: Interval; VAR p: Surround; ); (* Extracts from "b" the eight neighbors of pixel "b[00,00]", in clockwise order and saves them in "p[0..7]". Also extracts the center pixel "b[00,00]" itself and returns it in "c". *) PROCEDURE LineIndicator( c: Interval; READONLY p: ARRAY [0..7] OF Interval; factor: BOOL; ): Interval; (* Given a pixel "c" and its 8 neighbors "p[0..7]", already normalized, returns the line indicator operator. If "factor" is true, returns only the "h" factor. *) PROCEDURE ShiftPixels( READONLY p: ARRAY [0..7] OF Interval; VAR q: ARRAY [0..7] OF Interval; ); (* Shifts cyclically the pixels "p[0..7]" by half a pixel, resulting in pixels "q[0..7]". *) END LineOps.