UNPKG

3.42 kBtext/x-cView Raw
1// Copyright 2013 Lovell Fuller and others.
2// SPDX-License-Identifier: Apache-2.0
3
4#ifndef SRC_OPERATIONS_H_
5#define SRC_OPERATIONS_H_
6
7#include <algorithm>
8#include <functional>
9#include <memory>
10#include <tuple>
11#include <vips/vips8>
12
13using vips::VImage;
14
15namespace sharp {
16
17 /*
18 * Tint an image using the provided RGB.
19 */
20 VImage Tint(VImage image, std::vector<double> const tint);
21
22 /*
23 * Stretch luminance to cover full dynamic range.
24 */
25 VImage Normalise(VImage image, int const lower, int const upper);
26
27 /*
28 * Contrast limiting adapative histogram equalization (CLAHE)
29 */
30 VImage Clahe(VImage image, int const width, int const height, int const maxSlope);
31
32 /*
33 * Gamma encoding/decoding
34 */
35 VImage Gamma(VImage image, double const exponent);
36
37 /*
38 * Flatten image to remove alpha channel
39 */
40 VImage Flatten(VImage image, std::vector<double> flattenBackground);
41
42 /*
43 * Produce the "negative" of the image.
44 */
45 VImage Negate(VImage image, bool const negateAlpha);
46
47 /*
48 * Gaussian blur. Use sigma of -1.0 for fast blur.
49 */
50 VImage Blur(VImage image, double const sigma, VipsPrecision precision, double const minAmpl);
51
52 /*
53 * Convolution with a kernel.
54 */
55 VImage Convolve(VImage image, int const width, int const height,
56 double const scale, double const offset, std::vector<double> const &kernel_v);
57
58 /*
59 * Sharpen flat and jagged areas. Use sigma of -1.0 for fast sharpen.
60 */
61 VImage Sharpen(VImage image, double const sigma, double const m1, double const m2,
62 double const x1, double const y2, double const y3);
63
64 /*
65 Threshold an image
66 */
67 VImage Threshold(VImage image, double const threshold, bool const thresholdColor);
68
69 /*
70 Perform boolean/bitwise operation on image color channels - results in one channel image
71 */
72 VImage Bandbool(VImage image, VipsOperationBoolean const boolean);
73
74 /*
75 Perform bitwise boolean operation between images
76 */
77 VImage Boolean(VImage image, VImage imageR, VipsOperationBoolean const boolean);
78
79 /*
80 Trim an image
81 */
82 VImage Trim(VImage image, std::vector<double> background, double threshold, bool const lineArt);
83
84 /*
85 * Linear adjustment (a * in + b)
86 */
87 VImage Linear(VImage image, std::vector<double> const a, std::vector<double> const b);
88
89 /*
90 * Unflatten
91 */
92 VImage Unflatten(VImage image);
93
94 /*
95 * Recomb with a Matrix of the given bands/channel size.
96 * Eg. RGB will be a 3x3 matrix.
97 */
98 VImage Recomb(VImage image, std::vector<double> const &matrix);
99
100 /*
101 * Modulate brightness, saturation, hue and lightness
102 */
103 VImage Modulate(VImage image, double const brightness, double const saturation,
104 int const hue, double const lightness);
105
106 /*
107 * Ensure the image is in a given colourspace
108 */
109 VImage EnsureColourspace(VImage image, VipsInterpretation colourspace);
110
111 /*
112 * Split and crop each frame, reassemble, and update pageHeight.
113 */
114 VImage CropMultiPage(VImage image, int left, int top, int width, int height,
115 int nPages, int *pageHeight);
116
117 /*
118 * Split into frames, embed each frame, reassemble, and update pageHeight.
119 */
120 VImage EmbedMultiPage(VImage image, int left, int top, int width, int height,
121 VipsExtend extendWith, std::vector<double> background, int nPages, int *pageHeight);
122
123} // namespace sharp
124
125#endif // SRC_OPERATIONS_H_