ImagerSampler.mesa
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
Michael Plass, August 7, 1984 3:17:05 pm PDT
Doug Wyatt, March 7, 1985 2:42:49 pm PST
DIRECTORY
ImagerPixelMap USING [PixelMap],
ImagerPixelRow USING [PixelRow],
ImagerTransformation USING [Transformation],
Scaled USING [Value];
ImagerSampler: CEDAR DEFINITIONS
~ BEGIN
PixelMap: TYPE ~ ImagerPixelMap.PixelMap;
Transformation: TYPE ~ ImagerTransformation.Transformation;
Pixel: TYPE ~ CARDINAL;
PixelRow: TYPE ~ ImagerPixelRow.PixelRow;
Sampler: TYPE ~ REF SamplerRep;
SamplerRep: TYPE ~ RECORD [
m: Transformation,
x, y: INTEGER,
sPixels, fPixels: NAT,
sStart, fStart: Scaled.Value, -- InverseTransform[m, [x+0.5, y+0.5]] MOD [sPixels, fPixels]
sDelta, fDelta: Scaled.Value, -- InverseTransformVec[m, [0, 1]]
sDeltaLine, fDeltaLine: Scaled.Value -- InverseTransformVec[m, [1, 0]]
];
CreateSampler: PROC [m: Transformation, x, y: INTEGER, sPixels, fPixels: NAT] RETURNS [sampler: Sampler];
SetSamplePosition: PROC [sampler: Sampler, x, y: INTEGER];
Incremental, assuming sampleHandle is already correct.
ObtainPointSamples: PROC [pixelRow: PixelRow, source: PixelMap, sampler: Sampler, multiplier: CARDINAL ← 1, lgScale: INTEGER ← 0];
Uses [pixelRow.sOrigin, pixelRow.fOrigin] to set [sampler.x, sampler.y]
Fetches only sample points that fall within source.BoundedWindow
Unfetched samples are unchanged in the buffer
Pixel values are multiplied by multiplier*2**lgScale
ObtainInterpolatedSamples: PROC [pixelRow: PixelRow, source: PixelMap, sampler: Sampler, multiplier: CARDINAL ← 1, lgScale: INTEGER ← 0];
Interpolates four surrounding pixels to get result
Pixel values are multiplied by multiplier*2**lgScale before interpolation
HalftoneLine: PROC [dest: PixelMap, pixels: PixelRow, thresholds: PixelRow, invertOutput: BOOLEANFALSE, transparent: BOOLEANFALSE];
Each threshold is the minimum pixel value that should be displayed as white.
White = IF invertOutput THEN 1 ELSE 0
DotScreen: PROC [r: REAL ← 0.5, sSize: NAT ← 16, fSize: NAT ← 16, maxPixelValue: CARDINAL] RETURNS [pixelMap: PixelMap];
Creates a pixelMap with thresholds derived from two crossed cosines, uncorrected TRC.
ApplyTRC: PROC [thresholds: PixelMap, trc: PROC [x: REAL] RETURNS [y: REAL], maxPixelValue: CARDINAL];
Adjusts the values in the pixelMap so they turn on according to the given transfer function.
The x values of trc specify the inputs, as fractions of maxPixelValue.
The y values of trc specify the outputs, as (number of black pixels)/(sSize*fSize)
Both x and y range over [0.0..1.0]
Trc should be a nondecreasing function.
Identity: PROC [x: REAL] RETURNS [y: REAL];
Just returns y.
END.