Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mlib_imagesubsamplebinarytogray(3mlib) [sunos man page]

mlib_ImageSubsampleBinaryToGray(3MLIB)			    mediaLib Library Functions			    mlib_ImageSubsampleBinaryToGray(3MLIB)

NAME
mlib_ImageSubsampleBinaryToGray - subsamples a binary image and converts it to a grayscale image SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ] #include <mlib.h> mlib_status mlib_ImageSubsampleBinaryToGray(mlib_image *dst, const mlib_image *src, mlib_d64 xscale, mlib_d64 yscale, const mlib_u8 *lutGray); DESCRIPTION
The mlib_ImageSubsampleBinaryToGray() function subsamples a binary (MLIB_BIT) image and converts it to a grayscale (MLIB_BYTE) image. The subsampling algorithm performs the scaling operation by accumulating all the bits in the source image that correspond to the destina- tion 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==NULL). 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 colormap 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 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 over- run 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 MLIB_BYTE and have just one channel. src Pointer to source image. It must be of type MLIB_BIT 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 MLIB_SUCCESS if successful. Otherwise it returns MLIB_FAILURE. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mlib_ImageZoomTranslateToGray(3MLIB), mlib_ImageSubsampleAverage(3MLIB), attributes(5) SunOS 5.10 10 Nov 2004 mlib_ImageSubsampleBinaryToGray(3MLIB)
Man Page