iipsrv 1.2
iipsrv is an advanced high-performance feature-rich image server for web-based streamed viewing and zooming of ultra high-resolution images
Transforms.h
1/*
2 Image Transforms
3
4 Copyright (C) 2004-2022 Ruven Pillay.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19*/
20
21
22#ifndef _TRANSFORMS_H
23#define _TRANSFORMS_H
24
25#include <vector>
26#include "RawTile.h"
27
28
29// Define round() function for older MSVC compilers
30#if defined _MSC_VER && _MSC_VER<1900
31inline double round(double r) { return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5); }
32#endif
33
34
35enum interpolation { NEAREST, BILINEAR, CUBIC, LANCZOS2, LANCZOS3 };
36enum cmap_type { HOT, COLD, JET, BLUE, GREEN, RED };
37
38
40struct Transform {
41
42 private:
43
45
48 void LAB2sRGB( unsigned char *in, unsigned char *out );
49
50
51 public:
52
54 std::string getDescription() const { return "CPU processor"; };
55
56
58
62 void normalize( RawTile& in, const std::vector<float>& max, const std::vector<float>& min );
63
64
66
69 void cmap( RawTile& in, enum cmap_type cmap );
70
71
73
75 void inv( RawTile& in );
76
77
79
83 void shade( RawTile& in, int h_angle, int v_angle );
84
85
87
88 void LAB2sRGB( RawTile& in );
89
90
92
94
95
97
100 void contrast( RawTile& in, float c );
101
102
104
107 void gamma( RawTile& in, float g );
108
109
111
113 void log( RawTile& in );
114
115
117
121 void interpolate_nearestneighbour( RawTile& in, unsigned int w, unsigned int h );
122
123
125
129 void interpolate_bilinear( RawTile& in, unsigned int w, unsigned int h );
130
131
133
137 void rotate( RawTile& in, float angle );
138
139
141
142 void greyscale( RawTile& in );
143
144
146
149 void twist( RawTile& in, const std::vector< std::vector<float> >& ctw );
150
151
153
156 void flatten( RawTile& in, int bands );
157
158
160
163 void flip( RawTile& in, int o );
164
165
167
172 std::vector<unsigned int> histogram( RawTile& in, const std::vector<float>& max, const std::vector<float>& min );
173
174
176
179 unsigned char threshold( std::vector<unsigned int>& histogram );
180
181
183
186 void binary( RawTile& in, unsigned char threshold );
187
188
190
193 void equalize( RawTile& in, std::vector<unsigned int>& histogram );
194
195
197
200 void convolution( RawTile& in, const std::vector<float>& conv );
201
202
203};
204
205#endif
Class to represent a single image tile.
Definition: RawTile.h:47
Image Processing Transforms.
Definition: Transforms.h:40
void inv(RawTile &in)
Function to invert colormaps.
void LAB2sRGB(RawTile &in)
Convert from CIELAB to sRGB colour space.
std::string getDescription() const
Get description of processing engine.
Definition: Transforms.h:54
unsigned char threshold(std::vector< unsigned int > &histogram)
Calculate threshold for binary (bi-level) segmentation.
void binary(RawTile &in, unsigned char threshold)
Create binary (bi-level) image.
void gamma(RawTile &in, float g)
Apply a gamma correction (exponential transform)
void twist(RawTile &in, const std::vector< std::vector< float > > &ctw)
Apply a color twist.
void cmap(RawTile &in, enum cmap_type cmap)
Function to apply colormap to gray images.
void rotate(RawTile &in, float angle)
Rotate image - currently only by 90, 180 or 270 degrees, other values will do nothing.
std::vector< unsigned int > histogram(RawTile &in, const std::vector< float > &max, const std::vector< float > &min)
Calculate histogram of an image.
void log(RawTile &in)
Apply log transform: out = c log( 1 + in )
void convolution(RawTile &in, const std::vector< float > &conv)
Apply convolution.
void normalize(RawTile &in, const std::vector< float > &max, const std::vector< float > &min)
Function to create normalized array.
void greyscale(RawTile &in)
Convert image to grayscale.
void flatten(RawTile &in, int bands)
Extract bands.
void scale_to_8bit(RawTile &in)
Fast efficient scaling from higher fixed point bit depths to 8 bit.
void flip(RawTile &in, int o)
Flip image.
void interpolate_nearestneighbour(RawTile &in, unsigned int w, unsigned int h)
Resize image using nearest neighbour interpolation.
void interpolate_bilinear(RawTile &in, unsigned int w, unsigned int h)
Resize image using bilinear interpolation.
void shade(RawTile &in, int h_angle, int v_angle)
Hillshading function to simulate raking light images.
void contrast(RawTile &in, float c)
Function to apply a contrast adjustment and clip to 8 bit.
void equalize(RawTile &in, std::vector< unsigned int > &histogram)
Apply histogram equalization to an image.