iipsrv  1.1
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-2019 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
31 inline double round(double r) { return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5); }
32 #endif
33 
34 
35 enum interpolation { NEAREST, BILINEAR, CUBIC, LANCZOS2, LANCZOS3 };
36 enum cmap_type { HOT, COLD, JET, BLUE, GREEN, RED };
37 
38 
40 struct Transform {
41 
42  private:
43 
45 
48  void LAB2sRGB( unsigned char *in, unsigned char *out );
49 
50 
51  public:
52 
54  std::string getDescription(){ 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 
95  void contrast( RawTile& in, float c );
96 
97 
99 
102  void gamma( RawTile& in, float g );
103 
104 
106 
110  void interpolate_nearestneighbour( RawTile& in, unsigned int w, unsigned int h );
111 
112 
114 
118  void interpolate_bilinear( RawTile& in, unsigned int w, unsigned int h );
119 
120 
122 
126  void rotate( RawTile& in, float angle );
127 
128 
130 
131  void greyscale( RawTile& in );
132 
133 
135 
138  void twist( RawTile& in, const std::vector< std::vector<float> >& ctw );
139 
140 
142 
145  void flatten( RawTile& in, int bands );
146 
147 
149 
152  void flip( RawTile& in, int o );
153 
154 
156 
161  std::vector<unsigned int> histogram( RawTile& in, const std::vector<float>& max, const std::vector<float>& min );
162 
163 
165 
168  unsigned char threshold( std::vector<unsigned int>& histogram );
169 
170 
172 
175  void binary( RawTile& in, unsigned char threshold );
176 
177 
179 
182  void equalize( RawTile& in, std::vector<unsigned int>& histogram );
183 
184 
185 };
186 
187 #endif
void interpolate_bilinear(RawTile &in, unsigned int w, unsigned int h)
Resize image using bilinear interpolation.
void normalize(RawTile &in, const std::vector< float > &max, const std::vector< float > &min)
Function to create normalized array.
void inv(RawTile &in)
Function to invert colormaps.
std::vector< unsigned int > histogram(RawTile &in, const std::vector< float > &max, const std::vector< float > &min)
Calculate histogram of an image.
unsigned char threshold(std::vector< unsigned int > &histogram)
Calculate threshold for binary (bi-level) segmentation.
void gamma(RawTile &in, float g)
Apply a gamma correction.
void contrast(RawTile &in, float c)
Function to apply a contrast adjustment and clip to 8 bit.
void greyscale(RawTile &in)
Convert image to grayscale.
void flatten(RawTile &in, int bands)
Extract bands.
void cmap(RawTile &in, enum cmap_type cmap)
Function to apply colormap to gray images.
void shade(RawTile &in, int h_angle, int v_angle)
Hillshading function to simulate raking light images.
void equalize(RawTile &in, std::vector< unsigned int > &histogram)
Apply histogram equalization to an image.
Image Processing Transforms.
Definition: Transforms.h:40
void interpolate_nearestneighbour(RawTile &in, unsigned int w, unsigned int h)
Resize image using nearest neighbour interpolation.
void rotate(RawTile &in, float angle)
Rotate image - currently only by 90, 180 or 270 degrees, other values will do nothing.
void flip(RawTile &in, int o)
Flip image.
Class to represent a single image tile.
Definition: RawTile.h:45
std::string getDescription()
Get description of processing engine.
Definition: Transforms.h:54
void binary(RawTile &in, unsigned char threshold)
Create binary (bi-level) image.
void twist(RawTile &in, const std::vector< std::vector< float > > &ctw)
Apply a color twist.