GridModulation.mesa
Copyright (C) 1984, Xerox Corporation. All rights reserved.
Michael Plass, October 17, 1985 2:19:25 pm PDT
DIRECTORY ImagerPixelSeq, ImagerPixelMap, RasterFontIO;
GridModulation: CEDAR DEFINITIONS ~ BEGIN
PixelMap: TYPE ~ ImagerPixelMap.PixelMap;
PixelSeq: TYPE ~ ImagerPixelSeq.PixelSeq;
RealSeq: TYPE ~ REF RealSeqRep;
RealSeqRep: TYPE ~ RECORD [SEQUENCE length: NAT OF REAL];
EdgeProjection: TYPE ~ REF EdgeProjectionRep;
EdgeProjectionRep: TYPE ~ RECORD [
reductionFactor: NAT,
weight: INT,
sProjection: BOOLEAN,
origin: INTEGER,
size: NAT,
buffer: PixelSeq,
penalty: RealSeq,
totalBadness: RealSeq,
link: PixelSeq,
bestEnd: NAT,
swathStart: INTEGER,
swathSize: NAT
];
OptimizationParameters: TYPE ~ RECORD [
Parameters for controlling how the various things that are to be optimized for are to be weighted.
evenness: REAL ← 1.0,
Larger values of this encourage the grid lines to be more evenly spaced.
penaltyWeight: REAL ← 1.0,
The weight applied to contributions from the penalty array.
edgePinning: REAL ← 1.0,
Larger values of this encourage the grid lines around the edges to be displaced less from their ideal positions; may be important to get a consistent height.
maxOutputDeviation: REAL ← 1.0
Limit on how far the features are allowed to move, expressed in terms of output pixels.
];
StrokeHistogram: TYPE ~ REF StrokeHistogramRep;
StrokeHistogramRep: TYPE ~ RECORD [
size: NAT,
count: PixelSeq
];
RunSizeMap: TYPE ~ PixelSeq;
RunSizeMapFromHistogram: PUBLIC PROC [hist: StrokeHistogram, reductionFactor: NAT] RETURNS [RunSizeMap];
SimpleRunSizeMap: PUBLIC PROC [size: NAT, reductionFactor: NAT] RETURNS [RunSizeMap];
CreateEdgeProjection: PROC [sProjection: BOOLEAN, origin: INTEGER, size: NAT, reductionFactor: NAT, scratch: EdgeProjection ← NIL] RETURNS [EdgeProjection];
CreateStrokeHistogram: PROC [scratch: StrokeHistogram ← NIL] RETURNS [StrokeHistogram];
ProjectEdges: PROC [edgeProjection: EdgeProjection, pixelMap: PixelMap, runSizeMap: RunSizeMap];
AccumulateHistogram: PROC [strokeHistogram: StrokeHistogram, pixelMap: PixelMap, sProjection: BOOLEAN];
DetermineGrid: PROC [edgeProjection: EdgeProjection, param: OptimizationParameters];
Does the optimization step.
EnumerateSampleCoordinates: PROC [edgeProjection: EdgeProjection, action: PROC [inputPixelCoord: INTEGER, outputPixelCoord: INTEGER]];
ModulatedSample: PROC [sProjection, fProjection: EdgeProjection, pixelMap: PixelMap] RETURNS [PixelMap];
ConvertPixelMap: PROC [pixelMap: PixelMap, reductionFactor: INT, param: OptimizationParameters, runSizeMap: RunSizeMap, sScratch, fScratch: EdgeProjection] RETURNS [result: PixelMap];
ComputeConvolutionKernel: PROC [reductionFactor: INT] RETURNS [PixelMap];
Makes a convolution kernel of the appropriate size for the reductionFactor.
The result is 16 bits per pixel, normalized to add to LAST[CARDINAL]
GraySample: PROC [sProjection, fProjection: EdgeProjection, pixelMap: PixelMap, kernel: PixelMap, pmScratch: REF ImagerPixelMap.PixelMapRep ← NIL] RETURNS [PixelMap];
Makes an 8 bit-per-pixel image.
ConvertGrayPixelMap: PROC [pixelMap: PixelMap, reductionFactor: INT, param: OptimizationParameters, runSizeMap: RunSizeMap, kernel: PixelMap, sScratch, fScratch: EdgeProjection, pmScratch: REF ImagerPixelMap.PixelMapRep ← NIL] RETURNS [result: PixelMap];
ConvertFont: PROC [input: RasterFontIO.InternalFont, reductionFactor: INT, param: OptimizationParameters] RETURNS [RasterFontIO.InternalFont];
Look at the impl of this to see how to use the more basic operations.
END.