1mlib_ImageSubsampleBinaryTomGerdaiya(L3iMbLILBi)brarmyliFbu_nIcmtaigoenSsubsampleBinaryToGray(3MLIB)
2
3
4

NAME

6       mlib_ImageSubsampleBinaryToGray  -  subsamples  a binary image and con‐
7       verts it to a grayscale image
8

SYNOPSIS

10       cc [ flag... ] file... -lmlib [ library... ]
11       #include <mlib.h>
12
13       mlib_status mlib_ImageSubsampleBinaryToGray(mlib_image *dst,
14            const mlib_image *src, mlib_d64 xscale, mlib_d64 yscale,
15            const mlib_u8 *lutGray);
16
17

DESCRIPTION

19       The  mlib_ImageSubsampleBinaryToGray()  function  subsamples  a  binary
20       (MLIB_BIT) image and converts it to a grayscale (MLIB_BYTE) image.
21
22
23       The  subsampling algorithm performs the scaling operation by accumulat‐
24       ing all the bits in the source image that correspond to the destination
25       pixel  and, based on the x and y scaling factors, reserving consecutive
26       indexes in the colormap for the maximum number of gray levels  possible
27       in  the  destination  image. The destination image pixel values of this
28       function are either gray levels or indexes (if lutGray==NULL).
29
30
31       For representing the source block of pixels that is used  to  determine
32       destination  pixel  values,  the index 0 represents a block with no 1's
33       (all 0's), the index 1 represents a block with a single 1, and  so  on.
34       If  the  scaling factors require a fractional block of source pixels to
35       determine a destination pixel value, the block size is rounded up.  For
36       example,  if  a  2.2-by-2.2 block of source pixels would be required to
37       determine destination pixel values, a 3-by-3 block is  used,  resulting
38       in  10  possible  gray  levels and therefore 10 colormap indexes, whose
39       values are 0 through 9.
40
41
42       The width and height of the source block for a  destination  pixel  are
43       computed as:
44
45           blockX = (int)ceil(1.0/xscale);
46           blockY = (int)ceil(1.0/yscale);
47
48
49
50       If  we  denote  a pixel's location in an image by its column number and
51       row number (both counted from 0), the destination pixel at  (i,  j)  is
52       backward mapped to the source block whose upper-left corner pixel is at
53       (xValues[i], yValues[j]), where
54
55           xValues[i] = (int)(i/xscale + 0.5);
56           yValues[j] = (int)(j/yscale + 0.5);
57
58
59
60       The width and  height  of  the  filled  area  in  the  destination  are
61       restricted by
62
63           dstW = (int)(srcWidth * xscale);
64           dstH = (int)(srcHeight * yscale);
65
66
67
68       where srcWidth and srcHeight are width and height of the source image.
69
70
71       Since  the  block  size  in  source  is defined from scale factors with
72       roundup, some blocks (the rightmost  and  the  bottommost  blocks)  may
73       overrun  the  border of the source image by 1 pixel. In this case, such
74       blocks are moved by 1 pixel to left/up direction in order to be  inside
75       of the source image.
76

PARAMETERS

78       The function takes the following arguments:
79
80       dst        Pointer  to destination image . It must be of type MLIB_BYTE
81                  and have just one channel.
82
83
84       src        Pointer to source image. It must be  of  type  MLIB_BIT  and
85                  have just one channel.
86
87
88       xscale     X scale factor. 0.0 < xscale ≤ 1.0.
89
90
91       yscale     Y scale factor. 0.0 < yscale ≤ 1.0.
92
93
94       lutGray    Pointer to a grayscale lookup-table.
95
96

RETURN VALUES

98       The  function  returns MLIB_SUCCESS if successful. Otherwise it returns
99       MLIB_FAILURE.
100

ATTRIBUTES

102       See attributes(5) for descriptions of the following attributes:
103
104
105
106
107       ┌─────────────────────────────┬─────────────────────────────┐
108       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
109       ├─────────────────────────────┼─────────────────────────────┤
110       │Interface Stability          │Committed                    │
111       ├─────────────────────────────┼─────────────────────────────┤
112       │MT-Level                     │MT-Safe                      │
113       └─────────────────────────────┴─────────────────────────────┘
114

SEE ALSO

116       mlib_ImageZoomTranslateToGray(3MLIB),          mlib_ImageSubsampleAver‐
117       age(3MLIB), attributes(5)
118
119
120
121SunOS 5.11                        2 Mar 2m0l0i7b_ImageSubsampleBinaryToGray(3MLIB)
Impressum