Transforms.h
/*
Image Transforms
Copyright (C) 2004-2019 Ruven Pillay.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _TRANSFORMS_H
#define _TRANSFORMS_H
#include <vector>
#include "RawTile.h"
// Define round() function for older MSVC compilers
#if defined _MSC_VER && _MSC_VER<1900
inline double round(double r) { return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5); }
#endif
enum interpolation { NEAREST, BILINEAR, CUBIC, LANCZOS2, LANCZOS3 };
enum cmap_type { HOT, COLD, JET, BLUE, GREEN, RED };
struct Transform {
private:
void LAB2sRGB( unsigned char *in, unsigned char *out );
public:
std::string getDescription(){ return "CPU processor"; };
void normalize( RawTile& in, const std::vector<float>& max, const std::vector<float>& min );
void cmap( RawTile& in, enum cmap_type cmap );
void inv( RawTile& in );
void shade( RawTile& in, int h_angle, int v_angle );
void LAB2sRGB( RawTile& in );
void contrast( RawTile& in, float c );
void gamma( RawTile& in, float g );
void interpolate_nearestneighbour( RawTile& in, unsigned int w, unsigned int h );
void interpolate_bilinear( RawTile& in, unsigned int w, unsigned int h );
void rotate( RawTile& in, float angle );
void greyscale( RawTile& in );
void twist( RawTile& in, const std::vector< std::vector<float> >& ctw );
void flatten( RawTile& in, int bands );
void flip( RawTile& in, int o );
std::vector<unsigned int> histogram( RawTile& in, const std::vector<float>& max, const std::vector<float>& min );
unsigned char threshold( std::vector<unsigned int>& histogram );
void binary( RawTile& in, unsigned char threshold );
void equalize( RawTile& in, std::vector<unsigned int>& histogram );
};
#endif
RawTile
Class to represent a single image tile.
Definition RawTile.h:45
Transform
Image Processing Transforms.
Definition Transforms.h:40
Transform::inv
void inv(RawTile &in)
Function to invert colormaps.
Transform::LAB2sRGB
void LAB2sRGB(RawTile &in)
Convert from CIELAB to sRGB colour space.
Transform::threshold
unsigned char threshold(std::vector< unsigned int > &histogram)
Calculate threshold for binary (bi-level) segmentation.
Transform::binary
void binary(RawTile &in, unsigned char threshold)
Create binary (bi-level) image.
Transform::gamma
void gamma(RawTile &in, float g)
Apply a gamma correction.
Transform::twist
void twist(RawTile &in, const std::vector< std::vector< float > > &ctw)
Apply a color twist.
Transform::cmap
void cmap(RawTile &in, enum cmap_type cmap)
Function to apply colormap to gray images.
Transform::rotate
void rotate(RawTile &in, float angle)
Rotate image - currently only by 90, 180 or 270 degrees, other values will do nothing.
Transform::histogram
std::vector< unsigned int > histogram(RawTile &in, const std::vector< float > &max, const std::vector< float > &min)
Calculate histogram of an image.
Transform::getDescription
std::string getDescription()
Get description of processing engine.
Definition Transforms.h:54
Transform::normalize
void normalize(RawTile &in, const std::vector< float > &max, const std::vector< float > &min)
Function to create normalized array.
Transform::greyscale
void greyscale(RawTile &in)
Convert image to grayscale.
Transform::flatten
void flatten(RawTile &in, int bands)
Extract bands.
Transform::flip
void flip(RawTile &in, int o)
Flip image.
Transform::interpolate_nearestneighbour
void interpolate_nearestneighbour(RawTile &in, unsigned int w, unsigned int h)
Resize image using nearest neighbour interpolation.
Transform::interpolate_bilinear
void interpolate_bilinear(RawTile &in, unsigned int w, unsigned int h)
Resize image using bilinear interpolation.
Transform::shade
void shade(RawTile &in, int h_angle, int v_angle)
Hillshading function to simulate raking light images.
Transform::contrast
void contrast(RawTile &in, float c)
Function to apply a contrast adjustment and clip to 8 bit.
Transform::equalize
void equalize(RawTile &in, std::vector< unsigned int > &histogram)
Apply histogram equalization to an image.