1mlib_ImageSubsampleAverage(m3eMdLiIaBL)ib Library Funmcltiibo_nIsmageSubsampleAverage(3MLIB)
2
3
4
6 mlib_ImageSubsampleAverage, mlib_ImageSubsampleAverage_Fp - subsamples
7 an image with a box filter
8
10 cc [ flag... ] file... -lmlib [ library... ]
11 #include <mlib.h>
12
13 mlib_status mlib_ImageSubsampleAverage(mlib_image *dst,
14 const mlib_image *src, mlib_d64 xscale, mlib_d64 yscale);
15
16
17 mlib_status mlib_ImageSubsampleAverage_Fp(mlib_image *dst,
18 const mlib_image *src, mlib_d64 xscale, mlib_d64 yscale);
19
20
22 Each function scales an image down with an adaptive box filter.
23
24
25 The subsampling algorithm performs the scaling operation by averaging
26 all the pixel values from a block in the source image that correspond
27 to the destination pixel.
28
29
30 The width and height of the source block for a destination pixel are
31 computed as:
32
33 blockX = (int)ceil(1.0/xscale);
34 blockY = (int)ceil(1.0/yscale);
35
36
37
38 If we denote a pixel's location in an image by its column number and
39 row number (both counted from 0), the destination pixel at (i, j) is
40 backward mapped to the source block whose upper-left corner pixel is at
41 (xValues[i], yValues[j]), where
42
43 xValues[i] = (int)(i/xscale + 0.5);
44 yValues[j] = (int)(j/yscale + 0.5);
45
46
47
48 The width and height of the filled area in the destination are
49 restricted by
50
51 dstW = (int)(srcWidth * xscale);
52 dstH = (int)(srcHeight * yscale);
53
54
55
56 where srcWidth and srcHeight are width and height of the source image.
57
58
59 Since the block size in source is defined from scale factors with
60 roundup, some blocks (the rightmost and the bottommost blocks) may
61 overrun the border of the source image by 1 pixel. In this case, such
62 blocks are moved by 1 pixel to left/up direction in order to be inside
63 of the source image.
64
66 The function takes the following arguments:
67
68 dst Pointer to destination image.
69
70
71 src Pointer to source image.
72
73
74 xscale X scale factor. 0.0 < xscale ≤ 1.0.
75
76
77 yscale Y scale factor. 0.0 < yscale ≤ 1.0.
78
79
81 The function returns MLIB_SUCCESS if successful. Otherwise it returns
82 MLIB_FAILURE.
83
85 See attributes(5) for descriptions of the following attributes:
86
87
88
89
90 ┌─────────────────────────────┬─────────────────────────────┐
91 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
92 ├─────────────────────────────┼─────────────────────────────┤
93 │Interface Stability │Committed │
94 ├─────────────────────────────┼─────────────────────────────┤
95 │MT-Level │MT-Safe │
96 └─────────────────────────────┴─────────────────────────────┘
97
99 mlib_ImageSubsampleBinaryToGray(3MLIB), mlib_ImageFilteredSubsam‐
100 ple(3MLIB), mlib_ImageZoomTranslate(3MLIB), mlib_ImageZoomTrans‐
101 late_Fp(3MLIB), attributes(5)
102
103
104
105SunOS 5.11 2 Mar 2007 mlib_ImageSubsampleAverage(3MLIB)