(* field-def.sml
*
* COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
* All rights reserved.
*)
structure FieldDef =
struct
(* the static definition of a field value *)
datatype field_def =
= CONV of ImageInfo.info * Kernel.kernel (* convolution *)
| DIFF of int * field_def (* k levels of differentiation *)
| NEG of field_def
| SUM of field_def * field_def
(* scaling too? *)
(* normalize a field definition by pushing the DIFF operators to the
* leaves
*)
fun normalize fld = let
fun norm fld = (case fld
of CONV _ => fld
| DIFF(k, fld) => diff (k, fld)
| NEG fld => NEG(norm fld)
| SUM(fld1, fld2) => SUM(norm fld1, norm fld2)
(* end case *))
and diff (k, fld) = (case fld
of CONV _ => DIFF(k, fld)
| DIFF(k', fld) => diff (k+k', fld)
| NEG fld => NEG(diff(k, fld))
| SUM(fld1, fld2) => SUM(diff(k, fld1), diff(k, fld2))
(* end case *))
in
norm fld
end
end