mediaLib Library Functions
mlibImageSubsampleBinaryToGray(3MLIB)
NAME
mlibImageSubsampleBinaryToGray - subsamples a binary image
and converts it to a grayscale image
SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ]
#include
mlibstatus mlibImageSubsampleBinaryToGray(mlibimage *dst,
const mlibimage *src, mlibd64 xscale, mlibd64 yscale,
const mlibu8 *lutGray);
DESCRIPTION
The mlibImageSubsampleBinaryToGray() function subsamples a
binary (MLIBIT) image and converts it to a grayscale
(MLIBYTE) image.
The subsampling algorithm performs the scaling operation by
accumulating all the bits in the source image that
correspond to the destination pixel and, based on the x and
y scaling factors, reserving consecutive indexes in the
colormap for the maximum number of gray levels possible in
the destination image. The destination image pixel values of
this function are either gray levels or indexes (if
lutGray==NUL).
For representing the source block of pixels that is used to
determine destination pixel values, the index 0 represents a
block with no 1's (all 0's), the index 1 represents a block
with a single 1, and so on. If the scaling factors require a
fractional block of source pixels to determine a destination
pixel value, the block size is rounded up. For example, if a
2.2-by-2.2 block of source pixels would be required to
determine destination pixel values, a 3-by-3 block is used,
resulting in 10 possible gray levels and therefore 10 color-
map indexes, whose values are 0 through 9.
The width and height of the source block for a destination
pixel are computed as:
blockX = (int)ceil(1.0/xscale);
blockY = (int)ceil(1.0/yscale);
If we denote a pixel's location in an image by its column
number and row number (both counted from 0), the destination
SunOS 5.11 Last change: 2 Mar 2007 1
mediaLib Library Functions
mlibImageSubsampleBinaryToGray(3MLIB)
pixel at (i, j) is backward mapped to the source block whose
upper-left corner pixel is at (xValues[i], yValues[j]),
where
xValues[i] = (int)(i/xscale ] 0.5);
yValues[j] = (int)(j/yscale ] 0.5);
The width and height of the filled area in the destination
are restricted by
dstW = (int)(srcWidth * xscale);
dstH = (int)(srcHeight * yscale);
where srcWidth and srcHeight are width and height of the
source image.
Since the block size in source is defined from scale factors
with roundup, some blocks (the rightmost and the bottommost
blocks) may overrun the border of the source image by 1
pixel. In this case, such blocks are moved by 1 pixel to
left/up direction in order to be inside of the source image.
PARAMETERS
The function takes the following arguments:
dst Pointer to destination image . It must be of type
MLIBYTE and have just one channel.
src Pointer to source image. It must be of type
MLIBIT and have just one channel.
xscale X scale factor. 0.0 < xscale < 1.0.
yscale Y scale factor. 0.0 < yscale < 1.0.
lutGray Pointer to a grayscale lookup-table.
RETURN VALUES
The function returns MLIBSUCES if successful. Otherwise
it returns MLIBFAILURE.
SunOS 5.11 Last change: 2 Mar 2007 2
mediaLib Library Functions
mlibImageSubsampleBinaryToGray(3MLIB)
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
Interface Stability Committed
MT-Level MT-Safe
SEE ALSO
mlibImageZoomTranslateToGray(3MLIB),
mlibImageSubsampleAverage(3MLIB), attributes(5)
SunOS 5.11 Last change: 2 Mar 2007 3
mediaLib Library Functions
mlibImageSubsampleBinaryToGray(3MLIB)
SunOS 5.11 Last change: 2 Mar 2007 4
|