cmodule2 URecog > DynPrintLog { // returns 0, 1 or 2 int posterizeToInt(double x) { ret ifloor(clampZeroToOne(x)*3); } // returns 0, .5 or 1 double posterizeInPlace(double x) { ret posterizeToInt(x)*.5; } class Cell { // Original image and which part we are looking at IIntegralImage image; DoubleRange xClip, yClip; // color transformations in place DoubleRange[] colorClips = new[3]; // make the root cell *(IIntegralImage *image) { xClip = yClip = doubleRange(0, 1); for i to 3: colorClips[i] = doubleRange(0, 1); } double color(int channel) { ret ii_averageBrightnessOfArea(image, toRect_floor( doubleRectFromRanges(xClip, yClip))); } } }