MVE - Multi-View Environment mve-devel
|
Image tools, loading and processing functions. More...
Classes | |
struct | ExifInfo |
EXIF information. More... | |
struct | ImageHeaders |
Image meta data. More... | |
Enumerations | |
enum | DesaturateType { DESATURATE_MAXIMUM , DESATURATE_LIGHTNESS , DESATURATE_LUMINOSITY , DESATURATE_LUMINANCE , DESATURATE_AVERAGE } |
Desaturaturation type. More... | |
enum | FlipType { FLIP_NONE = 0 , FLIP_HORIZONTAL = 1 << 0 , FLIP_VERTICAL = 1 << 1 , FLIP_BOTH = FLIP_HORIZONTAL | FLIP_VERTICAL } |
Image flipping type. More... | |
enum | RescaleInterpolation { RESCALE_NEAREST , RESCALE_LINEAR , RESCALE_GAUSSIAN } |
Rescale interpolation type. More... | |
enum | RotateType { ROTATE_CCW , ROTATE_CW , ROTATE_180 , ROTATE_SWAP } |
Image rotation type. More... | |
Functions | |
template<typename T > | |
Image< T >::Ptr | blur_boxfilter (typename Image< T >::ConstPtr in, int ks) |
Blurs the image using a box filter of integer size 'ks'. | |
template<typename T > | |
Image< T >::Ptr | blur_gaussian (typename Image< T >::ConstPtr in, float sigma) |
Blurs the image using a gaussian convolution kernel. | |
DoubleImage::Ptr | byte_to_double_image (ByteImage::ConstPtr image) |
Converts a given byte image to a double image. | |
FloatImage::Ptr | byte_to_float_image (ByteImage::ConstPtr image) |
Converts a given byte image to a float image. | |
template<typename T , typename FUNCTOR > | |
void | color_convert (typename Image< T >::Ptr image, FUNCTOR &converter) |
Applies an in-place color conversion to the given image. | |
template<typename T > | |
void | color_rgb_to_ycbcr (T *values) |
Converts an image from RGB to YCbCr color space according to http://en.wikipedia.org/wiki/YCbCr. | |
template<> | |
void | color_rgb_to_ycbcr< uint8_t > (uint8_t *v) |
template<typename T > | |
void | color_srgb_to_xyz (T *values) |
Converts linear sRGB values RGB into XYZ (CIE 1931) according to http://www.w3.org/Graphics/Color/sRGB. | |
template<> | |
void | color_srgb_to_xyz< uint8_t > (uint8_t *v) |
template<typename T > | |
void | color_xyy_to_xyz (T *values) |
Converts xyY colors to XYZ (CIE 1931) coordinates according to http://www.brucelindbloom.com/index.html?Eqn_xyY_to_XYZ.html. | |
template<> | |
void | color_xyy_to_xyz< uint8_t > (uint8_t *v) |
template<typename T > | |
void | color_xyz_to_srgb (T *values) |
Converts XYZ into linear sRGB values RGB according to http://www.w3.org/Graphics/Color/sRGB. | |
template<> | |
void | color_xyz_to_srgb< uint8_t > (uint8_t *v) |
template<typename T > | |
void | color_xyz_to_xyy (T *values) |
Converts XYZ colors to xyY coordinates according to http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_xyY.html. | |
template<> | |
void | color_xyz_to_xyy< uint8_t > (uint8_t *v) |
template<typename T > | |
void | color_ycbcr_to_rgb (T *values) |
Converts an image from YCbCr to RGB color space according to http://en.wikipedia.org/wiki/YCbCr. | |
template<> | |
void | color_ycbcr_to_rgb< uint8_t > (uint8_t *v) |
ImageBase::Ptr | create_for_type (ImageType type, int64_t width, int64_t height, int64_t chans) |
Creates an image instance for a given type. | |
template<typename T > | |
Image< T >::Ptr | create_thumbnail (typename Image< T >::ConstPtr image, int64_t thumb_width, int64_t thumb_height) |
Creates a thumbnail of the given size by first rescaling the image and then cropping to fill the thumbnail. | |
template<typename T > | |
Image< T >::Ptr | crop (typename Image< T >::ConstPtr image, int64_t width, int64_t height, int64_t left, int64_t top, T const *fill_color) |
Returns a sub-image by cropping against a rectangular region. | |
FloatImage::Ptr | depthmap_bilateral_filter (FloatImage::ConstPtr dm, math::Matrix3f const &invproj, float gc_sigma, float pc_fator) |
Filters the given depthmap using a bilateral filter. | |
FloatImage::Ptr | depthmap_cleanup (FloatImage::ConstPtr dm, int64_t thres) |
Algorithm to clean small confident islands in the depth maps. | |
void | depthmap_cleanup_grow (FloatImage::ConstPtr dm, FloatImage::Ptr ret, std::vector< bool > &visited, int64_t x, int64_t y, std::size_t thres) |
void | depthmap_confidence_clean (FloatImage::Ptr dm, FloatImage::ConstPtr cm) |
Removes the backplane according to the confidence map IN-PLACE. | |
template<typename T > | |
void | depthmap_convert_conventions (typename Image< T >::Ptr dm, math::Matrix3f const &invproj, bool to_mve) |
Converts between depth map conventions IN-PLACE. | |
template<typename T > | |
Image< T >::Ptr | desaturate (typename Image< T >::ConstPtr image, DesaturateType type) |
Desaturates an RGB or RGBA image to G or GA respectively. | |
template<typename T > | |
T | desaturate_average (T const *v) |
template<typename T > | |
T | desaturate_lightness (T const *v) |
template<typename T > | |
T | desaturate_luminance (T const *v) |
template<typename T > | |
T | desaturate_luminosity (T const *v) |
template<typename T > | |
T | desaturate_maximum (T const *v) |
template<typename T > | |
Image< T >::Ptr | difference (typename Image< T >::ConstPtr i1, typename Image< T >::ConstPtr i2) |
Creates a difference image by computing the absolute difference per value. | |
ByteImage::Ptr | double_to_byte_image (DoubleImage::ConstPtr image, double vmin=0.0, double vmax=1.0) |
Converts a given double image to a byte image. | |
template<typename T > | |
void | draw_circle (Image< T > &image, int64_t x, int64_t y, int64_t radius, T const *color) |
Draws a circle with midpoint (x,y) and given 'radius' on the image. | |
template<typename T > | |
void | draw_line (Image< T > &image, int64_t x1, int64_t y1, int64_t x2, int64_t y2, T const *color) |
Draws a line from (x0,y0) to (x1,y1) with given color on the image. | |
template<typename T > | |
void | draw_rectangle (Image< T > &image, int64_t x1, int64_t y1, int64_t x2, int64_t y2, T const *color) |
Draws a rectangle from (x1,y1) to (x2,y2) on the image. | |
void | exif_debug_print (std::ostream &stream, ExifInfo const &exif, bool indent=false) |
Prints the EXIF information to stream. | |
ExifInfo | exif_extract (char const *data, std::size_t len, bool is_jpeg=false) |
Function to extract a (selected) EXIF tags from binary data. | |
template<typename T > | |
Image< T >::Ptr | expand_grayscale (typename Image< T >::ConstPtr image) |
Expands a gray image (one or two channels) to an RGB or RGBA image. | |
template<typename T > | |
void | find_min_max_value (typename mve::Image< T >::ConstPtr image, T *vmin, T *vmax) |
Finds the smallest and largest value in the given image. | |
template<typename T > | |
void | flip (typename Image< T >::Ptr image, FlipType type) |
Flips the given image either horizontally, vertically or both IN-PLACE. | |
void | float_image_normalize (FloatImage::Ptr image) |
Normalizes a float image IN-PLACE such that all values are [0, 1]. | |
ByteImage::Ptr | float_to_byte_image (FloatImage::ConstPtr image, float vmin=0.0f, float vmax=1.0f) |
Converts a given float image to a byte image. | |
void | gamma_correct (ByteImage::Ptr image, float power) |
Applies fast gamma correction to byte image using a lookup table. | |
template<typename T > | |
void | gamma_correct (typename Image< T >::Ptr image, T const &power) |
Applies gamma correction to float/double images (in-place). | |
template<typename T > | |
void | gamma_correct_inv_srgb (typename Image< T >::Ptr image) |
Applies inverse gamma correction to float/double (in-place) images with nonlinear R'G'B' values in the range [0, 1] to linear sRGB values according to http://www.brucelindbloom.com/index.html?Eqn_RGB_to_XYZ.html: | |
template<typename T > | |
void | gamma_correct_srgb (typename Image< T >::Ptr image) |
Applies gamma correction to float/double images (in-place) with linear RGB values in range [0, 1] to nonlinear R'G'B' values according to http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_RGB.html: | |
template<typename T > | |
T | gaussian_kernel (typename Image< T >::ConstPtr img, float x, float y, int64_t c, float sigma) |
template<typename T > | |
Image< T >::Ptr | image_undistort_k2k4 (typename Image< T >::ConstPtr img, double focal_length, double k2, double k4) |
Undistorts the input image given the focal length of the image and two undistortion parameters. | |
template<typename T > | |
Image< T >::Ptr | image_undistort_msps (typename Image< T >::ConstPtr img, double k0, double k1) |
Undistorts the input image given the two undistortion parameters. | |
template<typename T > | |
Image< T >::Ptr | image_undistort_vsfm (typename Image< T >::ConstPtr img, double focal_length, double k1) |
Undistorts the input image given the focal length of the image and a single distortion parameter. | |
ByteImage::Ptr | int_to_byte_image (IntImage::ConstPtr image) |
Convertes a given int image to a byte image. | |
template<typename T_IN , typename T_OUT > | |
Image< T_OUT >::Ptr | integral_image (typename Image< T_IN >::ConstPtr image) |
Calculates the integral image (or summed area table) for the input image. | |
template<typename T > | |
T | integral_image_area (typename Image< T >::ConstPtr sat, int64_t x1, int64_t y1, int64_t x2, int64_t y2, int64_t cc=0) |
Sums over the rectangle defined by A=(x1,y1) and B=(x2,y2) on the given SAT for channel cc. | |
void | jpg_error_handler (j_common_ptr) |
void | jpg_message_handler (j_common_ptr, int msg_level) |
ByteImage::Ptr | load_file (std::string const &filename) |
Loads an image, detecting file type. | |
ImageHeaders | load_file_headers (std::string const &filename) |
Loads the image headers, detecting file type. | |
ByteImage::Ptr | load_jpg_file (std::string const &filename, std::string *exif=nullptr) |
Loads a JPEG file. | |
ImageHeaders | load_jpg_file_headers (std::string const &filename) |
Loads JPEG file headers only. | |
ImageBase::Ptr | load_mvei_file (std::string const &filename) |
Loads a native MVE image. | |
ImageHeaders | load_mvei_file_headers (std::string const &filename) |
Loads the meta information for a native MVE image. | |
FloatImage::Ptr | load_pfm_file (std::string const &filename) |
Loads a PFM file. | |
ByteImage::Ptr | load_png_file (std::string const &filename) |
Loads a PNG file. | |
ImageHeaders | load_png_file_headers (std::string const &filename) |
Loads PNG file headers only. | |
RawImage::Ptr | load_ppm_16_file (std::string const &filename) |
Loads a 16 bit PPM file. | |
ByteImage::Ptr | load_ppm_file (std::string const &filename) |
Loads a 8 bit PPM file. | |
ImageBase::Ptr | load_ppm_file_intern (std::string const &filename, bool bit8) |
RawImage::Ptr | load_tiff_16_file (std::string const &filename) |
Loads a 16bit TIFF file. | |
ByteImage::Ptr | load_tiff_file (std::string const &filename) |
Loads a TIFF file. | |
ImageHeaders | load_tiff_file_headers (std::string const &filename) |
Loads TIFF file headers only. | |
FloatImage::Ptr | load_tiff_float_file (std::string const &filename) |
Loads a 32bit float TIFF file. | |
ByteImage::Ptr | raw_to_byte_image (RawImage::ConstPtr image, uint16_t vmin=0, uint16_t vmax=65535) |
Converts a given raw image to a byte image. | |
FloatImage::Ptr | raw_to_float_image (RawImage::ConstPtr image) |
Converts a given raw image to a float image. | |
template<typename T > | |
void | reduce_alpha (typename mve::Image< T >::Ptr img) |
Reduce alpha: Reduces RGBA or GA images to RGB or G images. | |
template<typename T > | |
Image< T >::Ptr | rescale (typename Image< T >::ConstPtr image, RescaleInterpolation interp, int64_t width, int64_t height) |
Returns a rescaled version of 'image' with dimensions 'width' times 'height' using 'interp' for value interpolation. | |
template<typename T > | |
Image< T >::Ptr | rescale_double_size (typename Image< T >::ConstPtr img) |
Returns a rescaled version of the image, upscaled with linear interpolation by factor 2. | |
template<typename T > | |
Image< T >::Ptr | rescale_double_size_supersample (typename Image< T >::ConstPtr img) |
Returns a rescaled version of the image, upscaled with linear interpolation. | |
template<typename T > | |
void | rescale_gaussian (typename Image< T >::ConstPtr in, typename Image< T >::Ptr out, float sigma_factor=1.0f) |
Rescales image 'in' using a gaussian kernel mask. | |
template<typename T > | |
Image< T >::Ptr | rescale_half_size (typename Image< T >::ConstPtr image) |
Returns a rescaled version of image, scaled by factor 1/2, by grouping blocks of 2x2 pixel into one pixel in the new image. | |
template<typename T > | |
Image< T >::Ptr | rescale_half_size_gaussian (typename Image< T >::ConstPtr image, float sigma=0.866025403784439f) |
Returns a rescaled version of the image, scaled with a gaussian approximation by factor 1/2. | |
template<typename T > | |
Image< T >::Ptr | rescale_half_size_subsample (typename Image< T >::ConstPtr image) |
Returns a rescaled version of the image by subsampling every second column and row. | |
template<typename T > | |
void | rescale_linear (typename Image< T >::ConstPtr in, typename Image< T >::Ptr out) |
Rescales image 'in' using linear interpolation. | |
template<typename T > | |
void | rescale_nearest (typename Image< T >::ConstPtr in, typename Image< T >::Ptr out) |
Rescales image 'in' using nearest neighbor. | |
template<typename T > | |
Image< T >::Ptr | rotate (typename Image< T >::ConstPtr image, float angle, T const *fill_color) |
Returns an image created by rotating the input image by the given amount of degrees (in radian) in clock-wise direction. | |
template<typename T > | |
Image< T >::Ptr | rotate (typename Image< T >::ConstPtr image, RotateType type) |
Returns a rotated copy of the given image either rotated clock wise, counter-clock wise, with 180 degree or with swapped x- and y-axis. | |
void | save_file (ByteImage::ConstPtr image, std::string const &filename) |
Saves a byte image to file, detecting file type. | |
void | save_file (ByteImage::Ptr image, std::string const &filename) |
Saves a byte image to file, detecting file type. | |
void | save_jpg_file (ByteImage::ConstPtr image, std::string const &filename, int quality) |
Saves image data to a JPEG file. | |
void | save_mvei_file (ImageBase::ConstPtr image, std::string const &filename) |
Writes a native MVE image. | |
void | save_pfm_file (FloatImage::ConstPtr image, std::string const &filename) |
Saves float image data to PFM file. | |
void | save_png_file (ByteImage::ConstPtr image, std::string const &filename, int compression_level=1) |
Saves image data to a PNG file. | |
void | save_ppm_16_file (RawImage::ConstPtr image, std::string const &filename) |
Save a 16 bit PPM file. | |
void | save_ppm_file (ByteImage::ConstPtr image, std::string const &filename) |
Writes a 8 bit PPM file. | |
void | save_ppm_file_intern (ImageBase::ConstPtr image, std::string const &filename) |
void | save_tiff_16_file (RawImage::ConstPtr image, std::string const &filename) |
Writes a 16bit TIFF to file. | |
void | save_tiff_file (ByteImage::ConstPtr image, std::string const &filename) |
Writes a TIFF to file. | |
void | save_tiff_float_file (FloatImage::ConstPtr image, std::string const &filename) |
Writes a 32bit float TIFF to file. | |
template<typename T > | |
mve::Image< T >::Ptr | sobel_edge (typename mve::Image< T >::ConstPtr img) |
Implementation of the Sobel operator. | |
template<typename T > | |
Image< T >::Ptr | subtract (typename Image< T >::ConstPtr i1, typename Image< T >::ConstPtr i2) |
Subtracts two images to create the signed difference between the values. | |
void | tiff_error_handler (char const *, char const *fmt, va_list ap) |
template<typename SRC , typename DST > | |
Image< DST >::Ptr | type_to_type_image (typename Image< SRC >::ConstPtr image) |
Generic conversion between image types without scaling or clamping. | |
Image tools, loading and processing functions.
Desaturaturation type.
Definition at line 334 of file image_tools.h.
enum mve::image::FlipType |
Image flipping type.
Enumerator | |
---|---|
FLIP_NONE | |
FLIP_HORIZONTAL | |
FLIP_VERTICAL | |
FLIP_BOTH |
Definition at line 314 of file image_tools.h.
Rescale interpolation type.
Enumerator | |
---|---|
RESCALE_NEAREST | |
RESCALE_LINEAR | |
RESCALE_GAUSSIAN | Not suited for byte images. |
Definition at line 157 of file image_tools.h.
Image rotation type.
Enumerator | |
---|---|
ROTATE_CCW | Counter-clock wise rotation. |
ROTATE_CW | Clock wise rotation. |
ROTATE_180 | 180 degree rotation |
ROTATE_SWAP | Exchanges x- and y-axis. |
Definition at line 283 of file image_tools.h.
Image< T >::Ptr mve::image::blur_boxfilter | ( | typename Image< T >::ConstPtr | in, |
int | ks | ||
) |
Blurs the image using a box filter of integer size 'ks'.
The implementaion is separated, and much faster than Gaussian blur, but of inferior blur quality (usual box filter artifacts).
Definition at line 1110 of file image_tools.h.
Image< T >::Ptr mve::image::blur_gaussian | ( | typename Image< T >::ConstPtr | in, |
float | sigma | ||
) |
Blurs the image using a gaussian convolution kernel.
The implementation exploits kernel separability.
Definition at line 1026 of file image_tools.h.
DoubleImage::Ptr mve::image::byte_to_double_image | ( | ByteImage::ConstPtr | image | ) |
Converts a given byte image to a double image.
This is done by scaling from [0, 255] to [0, 1].
Definition at line 41 of file image_tools.cc.
FloatImage::Ptr mve::image::byte_to_float_image | ( | ByteImage::ConstPtr | image | ) |
Converts a given byte image to a float image.
This is done by scaling from [0, 255] to [0, 1].
Definition at line 23 of file image_tools.cc.
void mve::image::color_convert | ( | typename Image< T >::Ptr | image, |
FUNCTOR & | converter | ||
) |
Applies an in-place color conversion to the given image.
The conversion is performed by applying the given conversion functor to every pixel. The converter functor can either be a regular function which takes a pointer to the image pixel, or a conversion object which overloads operator() and takes a pointer to the image pixel.
The conversion function is expected to process pixels with 3 channels, and this function checks that images have at least 3 channels.
Note that color conversion with byte images is supported but not recommended. Color conversion often produces values outside the usual range and clamping occurs. Due to rounding and clampling, back and forth conversion (A -> B -> A') is often very unstable (A != A').
Definition at line 133 of file image_color.h.
void mve::image::color_rgb_to_ycbcr | ( | T * | values | ) |
Converts an image from RGB to YCbCr color space according to http://en.wikipedia.org/wiki/YCbCr.
Y 0.299000 0.587000 0.114000 R 0.0 Cb = -0.168736 -0.331264 0.500000 * G + 0.5 Cr 0.500000 -0.418688 -0.081312 B 0.5
Works with float, double and byte images.
Definition at line 281 of file image_color.h.
|
inline |
Definition at line 291 of file image_color.h.
void mve::image::color_srgb_to_xyz | ( | T * | values | ) |
Converts linear sRGB values RGB into XYZ (CIE 1931) according to http://www.w3.org/Graphics/Color/sRGB.
X 0.4124 0.3576 0.1805 R Y = 0.2126 0.7152 0.0722 * G Z 0.0193 0.1192 0.9505 B
Warning: Conversion of byte images is supported, but clamping can occur.
Definition at line 145 of file image_color.h.
|
inline |
Definition at line 155 of file image_color.h.
void mve::image::color_xyy_to_xyz | ( | T * | values | ) |
Converts xyY colors to XYZ (CIE 1931) coordinates according to http://www.brucelindbloom.com/index.html?Eqn_xyY_to_XYZ.html.
X = x * Y / y Y = Y Z = (1 - x - y) * Y / y
Warning: Conversion of byte images is supported, but clamping occurs. Also note that back and forth conversion with byte images is inaccurate.
Definition at line 193 of file image_color.h.
|
inline |
Definition at line 213 of file image_color.h.
void mve::image::color_xyz_to_srgb | ( | T * | values | ) |
Converts XYZ into linear sRGB values RGB according to http://www.w3.org/Graphics/Color/sRGB.
R 3.2410 -1.5374 -0.4986 X G = -0.9692 1.8760 0.0416 * Y B 0.0556 -0.2040 1.0570 Z
Warning: Conversion of byte images is supported, but clamping can occur.
Definition at line 169 of file image_color.h.
|
inline |
Definition at line 179 of file image_color.h.
void mve::image::color_xyz_to_xyy | ( | T * | values | ) |
Converts XYZ colors to xyY coordinates according to http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_xyY.html.
x = X / (X + Y + Z) y = Y / (X + Y + Z) Y = Y
Warning: Conversion of byte images is supported, but clamping occurs. Also note that back and forth conversion with byte images is inaccurate.
Definition at line 237 of file image_color.h.
|
inline |
Definition at line 257 of file image_color.h.
void mve::image::color_ycbcr_to_rgb | ( | T * | values | ) |
Converts an image from YCbCr to RGB color space according to http://en.wikipedia.org/wiki/YCbCr.
R 1.00 0.00000 1.40200 ( Y - 0.0 ) G = 1.00 -0.34414 -0.71414 * ( Cb - 0.5 ) B 1.00 1.77200 0.00000 ( Cr - 0.5 )
Works with float, double and byte images.
Definition at line 305 of file image_color.h.
|
inline |
Definition at line 318 of file image_color.h.
|
inline |
Image< T >::Ptr mve::image::create_thumbnail | ( | typename Image< T >::ConstPtr | image, |
int64_t | thumb_width, | ||
int64_t | thumb_height | ||
) |
Creates a thumbnail of the given size by first rescaling the image and then cropping to fill the thumbnail.
Definition at line 1659 of file image_tools.h.
Image< T >::Ptr mve::image::crop | ( | typename Image< T >::ConstPtr | image, |
int64_t | width, | ||
int64_t | height, | ||
int64_t | left, | ||
int64_t | top, | ||
T const * | fill_color | ||
) |
Returns a sub-image by cropping against a rectangular region.
Region may exceed the input image dimensions, new pixel values are initialized with the given color.
Definition at line 984 of file image_tools.h.
FloatImage::Ptr mve::image::depthmap_bilateral_filter | ( | FloatImage::ConstPtr | dm, |
math::Matrix3f const & | invproj, | ||
float | gc_sigma, | ||
float | pc_fator | ||
) |
Filters the given depthmap using a bilateral filter.
The filter smoothes similar depth values but preserves depth discontinuities using gaussian weights for both, geometric closeness in image space and geometric closeness in world space.
Geometric closeness in image space is controlled by 'gc_sigma' (useful values in [1, 20]). Photometric closeness is evaluated by calculating the pixel footprint multiplied with 'pc_factor' to detect depth discontinuities (useful values in [1, 20]).
FloatImage::Ptr mve::image::depthmap_cleanup | ( | FloatImage::ConstPtr | dm, |
int64_t | thres | ||
) |
Algorithm to clean small confident islands in the depth maps.
Islands that are smaller than 'thres' pixels are removed. Zero depth values are considered unreconstructed.
Definition at line 90 of file depthmap.cc.
void mve::image::depthmap_cleanup_grow | ( | FloatImage::ConstPtr | dm, |
FloatImage::Ptr | ret, | ||
std::vector< bool > & | visited, | ||
int64_t | x, | ||
int64_t | y, | ||
std::size_t | thres | ||
) |
Definition at line 25 of file depthmap.cc.
void mve::image::depthmap_confidence_clean | ( | FloatImage::Ptr | dm, |
FloatImage::ConstPtr | cm | ||
) |
Removes the backplane according to the confidence map IN-PLACE.
Depth map values are reset to zero where confidence is leq 0.
Definition at line 116 of file depthmap.cc.
|
inline |
Converts between depth map conventions IN-PLACE.
In one convention, a depth map with a constant value means a plane, in another convention, which is what MVE uses, a constant value creates a curved surface. The difference is whether only the z-value is considered, or the distance to the camera center is used (MVE).
Definition at line 169 of file depthmap.h.
Image< T >::Ptr mve::image::desaturate | ( | typename Image< T >::ConstPtr | image, |
DesaturateType | type | ||
) |
Desaturates an RGB or RGBA image to G or GA respectively.
A new image is returned, the original image is untouched.
From http://en.wikipedia.org/wiki/HSL_and_HSV#Lightness
Maximum = max(R,G,B) Lightness = 1/2 * (max(R,G,B) + min(R,G,B)) Luminosity = 0.21 * R + 0.72 * G + 0.07 * B Luminance = 0.30 * R + 0.59 * G + 0.11 * B Average Brightness = 1/3 * (R + G + B)
Definition at line 1349 of file image_tools.h.
|
inline |
Definition at line 1339 of file image_tools.h.
|
inline |
Definition at line 1316 of file image_tools.h.
|
inline |
Definition at line 1332 of file image_tools.h.
|
inline |
Definition at line 1325 of file image_tools.h.
|
inline |
Definition at line 1309 of file image_tools.h.
Image< T >::Ptr mve::image::difference | ( | typename Image< T >::ConstPtr | i1, |
typename Image< T >::ConstPtr | i2 | ||
) |
Creates a difference image by computing the absolute difference per value.
This works for unsigned image types but discards the sign. The function requires 'operator<' to be defined on the image value type.
Definition at line 1515 of file image_tools.h.
ByteImage::Ptr mve::image::double_to_byte_image | ( | DoubleImage::ConstPtr | image, |
double | vmin = 0.0 , |
||
double | vmax = 1.0 |
||
) |
Converts a given double image to a byte image.
This is done by clamping values to [vmin, vmax] and scaling to [0, 255].
Definition at line 78 of file image_tools.cc.
void mve::image::draw_circle | ( | Image< T > & | image, |
int64_t | x, | ||
int64_t | y, | ||
int64_t | radius, | ||
T const * | color | ||
) |
Draws a circle with midpoint (x,y) and given 'radius' on the image.
Length of the color array is expected to be the number of channels. TODO: No boundary checks are performed yet.
Definition at line 99 of file image_drawing.h.
void mve::image::draw_line | ( | Image< T > & | image, |
int64_t | x1, | ||
int64_t | y1, | ||
int64_t | x2, | ||
int64_t | y2, | ||
T const * | color | ||
) |
Draws a line from (x0,y0) to (x1,y1) with given color on the image.
Length of the color array is expected to be the number of channels. TODO: No boundary checks are performed yet.
Definition at line 61 of file image_drawing.h.
void mve::image::draw_rectangle | ( | Image< T > & | image, |
int64_t | x1, | ||
int64_t | y1, | ||
int64_t | x2, | ||
int64_t | y2, | ||
T const * | color | ||
) |
Draws a rectangle from (x1,y1) to (x2,y2) on the image.
Length of the color array is expected to be the number of channels.
Definition at line 141 of file image_drawing.h.
void mve::image::exif_debug_print | ( | std::ostream & | stream, |
ExifInfo const & | exif, | ||
bool | indent | ||
) |
Prints the EXIF information to stream.
Definition at line 443 of file image_exif.cc.
ExifInfo mve::image::exif_extract | ( | char const * | data, |
std::size_t | len, | ||
bool | is_jpeg = false |
||
) |
Function to extract a (selected) EXIF tags from binary data.
The function accepts pure EXIF binary data as read from the JPEG file, or the complete JPEG file. In the latter case, argument 'is_jpeg' needs to be true.
Definition at line 144 of file image_exif.cc.
Image< T >::Ptr mve::image::expand_grayscale | ( | typename Image< T >::ConstPtr | image | ) |
Expands a gray image (one or two channels) to an RGB or RGBA image.
Definition at line 1397 of file image_tools.h.
void mve::image::find_min_max_value | ( | typename mve::Image< T >::ConstPtr | image, |
T * | vmin, | ||
T * | vmax | ||
) |
Finds the smallest and largest value in the given image.
Definition at line 503 of file image_tools.h.
Flips the given image either horizontally, vertically or both IN-PLACE.
Definition at line 1279 of file image_tools.h.
void mve::image::float_image_normalize | ( | FloatImage::Ptr | image | ) |
Normalizes a float image IN-PLACE such that all values are [0, 1].
This is done by first finding the largest value in the image and dividing all image values by the largest value.
Definition at line 152 of file image_tools.cc.
ByteImage::Ptr mve::image::float_to_byte_image | ( | FloatImage::ConstPtr | image, |
float | vmin = 0.0f , |
||
float | vmax = 1.0f |
||
) |
Converts a given float image to a byte image.
This is done by clamping values to [vmin, vmax] and scaling to [0, 255].
Definition at line 59 of file image_tools.cc.
void mve::image::gamma_correct | ( | ByteImage::Ptr | image, |
float | power | ||
) |
Applies fast gamma correction to byte image using a lookup table.
Note that alpha channels are not treated as such and are also corrected!
Definition at line 171 of file image_tools.cc.
void mve::image::gamma_correct | ( | typename Image< T >::Ptr | image, |
T const & | power | ||
) |
Applies gamma correction to float/double images (in-place).
To obtain color values from linear intensities, use 1/2.2 as exponent. To remove gamma correction from an image, use 2.2 as exponent.
Definition at line 1545 of file image_tools.h.
void mve::image::gamma_correct_inv_srgb | ( | typename Image< T >::Ptr | image | ) |
Applies inverse gamma correction to float/double (in-place) images with nonlinear R'G'B' values in the range [0, 1] to linear sRGB values according to http://www.brucelindbloom.com/index.html?Eqn_RGB_to_XYZ.html:
X = X' / 12.92 if X' <= 0.04045 X = ((X' + 0.055) / (1.055))^2.4 otherwise
TODO: Implement overloading for integer image types.
Definition at line 1576 of file image_tools.h.
void mve::image::gamma_correct_srgb | ( | typename Image< T >::Ptr | image | ) |
Applies gamma correction to float/double images (in-place) with linear RGB values in range [0, 1] to nonlinear R'G'B' values according to http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_RGB.html:
X' = 12.92 * X if X <= 0.0031308 X' = 1.055 * X^(1/2.4) - 0.055 otherwise
TODO: Implement overloading for integer image types.
Definition at line 1555 of file image_tools.h.
T mve::image::gaussian_kernel | ( | typename Image< T >::ConstPtr | img, |
float | x, | ||
float | y, | ||
int64_t | c, | ||
float | sigma | ||
) |
Definition at line 890 of file image_tools.h.
Image< T >::Ptr mve::image::image_undistort_k2k4 | ( | typename Image< T >::ConstPtr | img, |
double | focal_length, | ||
double | k2, | ||
double | k4 | ||
) |
Undistorts the input image given the focal length of the image and two undistortion parameters.
The distortion model is computed as: rd(r) = 1 + k_2 r^2 + k_4 r^4 with r^2 = x^2 + y^2. The focal length is expected to be in unit format. This distortion model is used by MVE and Noah's bundler.
Definition at line 1733 of file image_tools.h.
Image< T >::Ptr mve::image::image_undistort_msps | ( | typename Image< T >::ConstPtr | img, |
double | k0, | ||
double | k1 | ||
) |
Undistorts the input image given the two undistortion parameters.
If both distortion parameters are equal, undistortion has no effect. This distortion model is used by Microsoft's Photosynther and is independent of the focal length.
Definition at line 1696 of file image_tools.h.
Image< T >::Ptr mve::image::image_undistort_vsfm | ( | typename Image< T >::ConstPtr | img, |
double | focal_length, | ||
double | k1 | ||
) |
Undistorts the input image given the focal length of the image and a single distortion parameter.
If the distortion parameter is 0, the undistortion has no effect. The focal length is expected to be in unit format. This distortion model is used by VisualSfM.
Definition at line 1775 of file image_tools.h.
ByteImage::Ptr mve::image::int_to_byte_image | ( | IntImage::ConstPtr | image | ) |
Convertes a given int image to a byte image.
Conversion is done by clamping absolute values.
Definition at line 97 of file image_tools.cc.
Image< T_OUT >::Ptr mve::image::integral_image | ( | typename Image< T_IN >::ConstPtr | image | ) |
Calculates the integral image (or summed area table) for the input image.
The integral image is computed channel-wise, i.e. the output image has the same amount of channels as the input image.
Definition at line 1597 of file image_tools.h.
T mve::image::integral_image_area | ( | typename Image< T >::ConstPtr | sat, |
int64_t | x1, | ||
int64_t | y1, | ||
int64_t | x2, | ||
int64_t | y2, | ||
int64_t | cc = 0 |
||
) |
Sums over the rectangle defined by A=(x1,y1) and B=(x2,y2) on the given SAT for channel cc.
This is efficiently calculated as B + A - C - D where C and D are the other two points of the rectange. The points A and B are considered to be INSIDE the rectangle.
Definition at line 1640 of file image_tools.h.
void mve::image::jpg_error_handler | ( | j_common_ptr | ) |
Definition at line 441 of file image_io.cc.
void mve::image::jpg_message_handler | ( | j_common_ptr | , |
int | msg_level | ||
) |
Definition at line 447 of file image_io.cc.
ByteImage::Ptr mve::image::load_file | ( | std::string const & | filename | ) |
Loads an image, detecting file type.
May throw util::Exception.
Definition at line 57 of file image_io.cc.
ImageHeaders mve::image::load_file_headers | ( | std::string const & | filename | ) |
Loads the image headers, detecting file type.
May throw util::Exception.
Definition at line 107 of file image_io.cc.
ByteImage::Ptr mve::image::load_jpg_file | ( | std::string const & | filename, |
std::string * | exif = nullptr |
||
) |
Loads a JPEG file.
The EXIF data blob may be loaded into 'exif'. JPEGs have 1 (gray values) or 3 (RGB) channels. May throw util::FileException and util::Exception.
Definition at line 454 of file image_io.cc.
ImageHeaders mve::image::load_jpg_file_headers | ( | std::string const & | filename | ) |
Loads JPEG file headers only.
May throw util::FileException and util::Exception.
Definition at line 533 of file image_io.cc.
ImageBase::Ptr mve::image::load_mvei_file | ( | std::string const & | filename | ) |
Loads a native MVE image.
Supports arbitrary type, size and depth, with a primitive, uncompressed format. May throw util::FileException.
Definition at line 1260 of file image_io.cc.
ImageHeaders mve::image::load_mvei_file_headers | ( | std::string const & | filename | ) |
Loads the meta information for a native MVE image.
Definition at line 1283 of file image_io.cc.
FloatImage::Ptr mve::image::load_pfm_file | ( | std::string const & | filename | ) |
Loads a PFM file.
Only handles 1 or 3 channel images of float values. No scaling is performed. May throw util::FileException and util::Exception.
Definition at line 975 of file image_io.cc.
ByteImage::Ptr mve::image::load_png_file | ( | std::string const & | filename | ) |
Loads a PNG file.
PNG has 1, 2, 3 or 4 channels with gray, gray-alpha, RGB or RGBA values. Conversion of 1, 2 and 4 to 8 bit is auto-applied. May throw util::FileException and util::Exception.
Definition at line 278 of file image_io.cc.
ImageHeaders mve::image::load_png_file_headers | ( | std::string const & | filename | ) |
Loads PNG file headers only.
May throw util::FileException and util::Exception.
Definition at line 334 of file image_io.cc.
RawImage::Ptr mve::image::load_ppm_16_file | ( | std::string const & | filename | ) |
Loads a 16 bit PPM file.
May throw util::FileException and util::Exception.
Definition at line 1156 of file image_io.cc.
ByteImage::Ptr mve::image::load_ppm_file | ( | std::string const & | filename | ) |
Loads a 8 bit PPM file.
May throw util::FileException and util::Exception.
Definition at line 1163 of file image_io.cc.
ImageBase::Ptr mve::image::load_ppm_file_intern | ( | std::string const & | filename, |
bool | bit8 | ||
) |
Definition at line 1088 of file image_io.cc.
RawImage::Ptr mve::image::load_tiff_16_file | ( | std::string const & | filename | ) |
Loads a 16bit TIFF file.
May throw util::FileException and util::Exception.
Definition at line 810 of file image_io.cc.
ByteImage::Ptr mve::image::load_tiff_file | ( | std::string const & | filename | ) |
Loads a TIFF file.
May throw util::FileException and util::Exception.
Definition at line 737 of file image_io.cc.
ImageHeaders mve::image::load_tiff_file_headers | ( | std::string const & | filename | ) |
Loads TIFF file headers only.
May throw util::FileException and util::Exception.
Definition at line 639 of file image_io.cc.
FloatImage::Ptr mve::image::load_tiff_float_file | ( | std::string const & | filename | ) |
Loads a 32bit float TIFF file.
May throw util::FileException and util::Exception.
Definition at line 887 of file image_io.cc.
ByteImage::Ptr mve::image::raw_to_byte_image | ( | RawImage::ConstPtr | image, |
uint16_t | vmin = 0 , |
||
uint16_t | vmax = 65535 |
||
) |
Converts a given raw image to a byte image.
This is done by clamping values to [vmin, vmax] and scaling to [0, 255].
Definition at line 114 of file image_tools.cc.
FloatImage::Ptr mve::image::raw_to_float_image | ( | RawImage::ConstPtr | image | ) |
Converts a given raw image to a float image.
This is done by scaling from [0, 65535] to [0, 1].
Definition at line 134 of file image_tools.cc.
void mve::image::reduce_alpha | ( | typename mve::Image< T >::Ptr | img | ) |
Reduce alpha: Reduces RGBA or GA images to RGB or G images.
Definition at line 1428 of file image_tools.h.
Image< T >::Ptr mve::image::rescale | ( | typename Image< T >::ConstPtr | image, |
RescaleInterpolation | interp, | ||
int64_t | width, | ||
int64_t | height | ||
) |
Returns a rescaled version of 'image' with dimensions 'width' times 'height' using 'interp' for value interpolation.
Set one of 'width' or 'height' to 0 to keep aspect ratio. Mipmap reduction is applied if the image is rescaled with size factor < 1/2.
Definition at line 523 of file image_tools.h.
Image< T >::Ptr mve::image::rescale_double_size | ( | typename Image< T >::ConstPtr | img | ) |
Returns a rescaled version of the image, upscaled with linear interpolation by factor 2.
In this version, only interpolated values are used to construct the new image. This is eliminates some original information but preserves the dimension/appearance of the image.
Definition at line 734 of file image_tools.h.
Image< T >::Ptr mve::image::rescale_double_size_supersample | ( | typename Image< T >::ConstPtr | img | ) |
Returns a rescaled version of the image, upscaled with linear interpolation.
Every second row and column is directly taken. This technique preserves all information (i.e. the original image can be recovered using rescale_half_size_subsample), but introduces a half pixel shift towards the upper left corner.
Definition at line 790 of file image_tools.h.
void mve::image::rescale_gaussian | ( | typename Image< T >::ConstPtr | in, |
typename Image< T >::Ptr | out, | ||
float | sigma_factor = 1.0f |
||
) |
Rescales image 'in' using a gaussian kernel mask.
The new image is scaled to the dimension of 'out', placing the result in 'out'. A smaller sigma factor produces more crisp results but aliased results, whereas a larger sigma factor produces smoother but blurred results. Warning: This function is terribly slow due to naive implementation.
Definition at line 953 of file image_tools.h.
Image< T >::Ptr mve::image::rescale_half_size | ( | typename Image< T >::ConstPtr | image | ) |
Returns a rescaled version of image, scaled by factor 1/2, by grouping blocks of 2x2 pixel into one pixel in the new image.
If the image size is odd, the new size is computed as new_size = (old_size + 1) / 2.
Definition at line 577 of file image_tools.h.
Image< T >::Ptr mve::image::rescale_half_size_gaussian | ( | typename Image< T >::ConstPtr | image, |
float | sigma = 0.866025403784439f |
||
) |
Returns a rescaled version of the image, scaled with a gaussian approximation by factor 1/2.
Note that the kernel size if fixed to 4x4 pixels, so sigma shouldn't be much larger than 1. The default sigma is sqrt(1.0^2 - 0.5^2) =~ 0.866 to double the inherent sigma of 0.5.
Definition at line 619 of file image_tools.h.
Image< T >::Ptr mve::image::rescale_half_size_subsample | ( | typename Image< T >::ConstPtr | image | ) |
Returns a rescaled version of the image by subsampling every second column and row.
Useful if the original image already has appropriate blur.
Definition at line 700 of file image_tools.h.
void mve::image::rescale_linear | ( | typename Image< T >::ConstPtr | in, |
typename Image< T >::Ptr | out | ||
) |
Rescales image 'in' using linear interpolation.
The new images is scaled to the dimensions of 'out', placing the result in 'out'. When downsampling, requires 'in' to be at appropriate mipmap level to avoid aliasing artifacts.
Definition at line 862 of file image_tools.h.
void mve::image::rescale_nearest | ( | typename Image< T >::ConstPtr | in, |
typename Image< T >::Ptr | out | ||
) |
Rescales image 'in' using nearest neighbor.
The new images is scaled to the dimensions of 'out', placing the result in 'out'. When downsampling, requires 'in' to be at appropriate mipmap level to avoid aliasing artifacts.
Definition at line 832 of file image_tools.h.
Image< T >::Ptr mve::image::rotate | ( | typename Image< T >::ConstPtr | image, |
float | angle, | ||
T const * | fill_color | ||
) |
Returns an image created by rotating the input image by the given amount of degrees (in radian) in clock-wise direction.
The size of the output image is the same as the input image, pixels may be rotated outside the view port and new pixels are filled with the provided fill color.
Definition at line 1244 of file image_tools.h.
Image< T >::Ptr mve::image::rotate | ( | typename Image< T >::ConstPtr | image, |
RotateType | type | ||
) |
Returns a rotated copy of the given image either rotated clock wise, counter-clock wise, with 180 degree or with swapped x- and y-axis.
Swapping x- and y-axis is not a real rotation but rather transposing. Note: In-place not supported because CW, CCW rotation and swap changes image dimensions. An in-place version of ROTATE_180 is available using in-place flipping in both directions.
Definition at line 1203 of file image_tools.h.
void mve::image::save_file | ( | ByteImage::ConstPtr | image, |
std::string const & | filename | ||
) |
Saves a byte image to file, detecting file type.
Saves a float image to file, detecting file type.
May throw util::Exception.
Definition at line 146 of file image_io.cc.
void mve::image::save_file | ( | ByteImage::Ptr | image, |
std::string const & | filename | ||
) |
Saves a byte image to file, detecting file type.
Saves a float image to file, detecting file type.
Overloaded for non-const pointers to avoid cast ambiguities. May throw util::Exception.
Definition at line 186 of file image_io.cc.
void mve::image::save_jpg_file | ( | ByteImage::ConstPtr | image, |
std::string const & | filename, | ||
int | quality | ||
) |
Saves image data to a JPEG file.
Supports 1 and 3 channel images. The quality value is in range [0, 100] from worst to best quality. May throw util::FileException and util::Exception.
Definition at line 580 of file image_io.cc.
void mve::image::save_mvei_file | ( | ImageBase::ConstPtr | image, |
std::string const & | filename | ||
) |
Writes a native MVE image.
Supports arbitrary type, size and depth, with a primitive, uncompressed format. May throw util::FileException.
Definition at line 1295 of file image_io.cc.
void mve::image::save_pfm_file | ( | FloatImage::ConstPtr | image, |
std::string const & | filename | ||
) |
Saves float image data to PFM file.
Supports 1 and 3 channel images. May throw util::FileException and util::Exception.
Definition at line 1045 of file image_io.cc.
void mve::image::save_png_file | ( | ByteImage::ConstPtr | image, |
std::string const & | filename, | ||
int | compression_level = 1 |
||
) |
Saves image data to a PNG file.
Supports 1, 2, 3 and 4 channel images. Valid compression levels are in [0, 9], 0 is fastest. May throw util::FileException and util::Exception.
Definition at line 354 of file image_io.cc.
void mve::image::save_ppm_16_file | ( | RawImage::ConstPtr | image, |
std::string const & | filename | ||
) |
Save a 16 bit PPM file.
Supports 1 and 3 channel images. May throw util::FileException and util::Exception.
Definition at line 1218 of file image_io.cc.
void mve::image::save_ppm_file | ( | ByteImage::ConstPtr | image, |
std::string const & | filename | ||
) |
Writes a 8 bit PPM file.
Supports 1 and 3 channel images. May throw util::FileException and std::invalid_argument.
Definition at line 1224 of file image_io.cc.
void mve::image::save_ppm_file_intern | ( | ImageBase::ConstPtr | image, |
std::string const & | filename | ||
) |
Definition at line 1170 of file image_io.cc.
void mve::image::save_tiff_16_file | ( | RawImage::ConstPtr | image, |
std::string const & | filename | ||
) |
Writes a 16bit TIFF to file.
Supports any number of channels. May throw util::FileException and util::Exception.
Definition at line 856 of file image_io.cc.
void mve::image::save_tiff_file | ( | ByteImage::ConstPtr | image, |
std::string const & | filename | ||
) |
Writes a TIFF to file.
Supports any number of channels. May throw util::FileException and util::Exception.
Definition at line 779 of file image_io.cc.
void mve::image::save_tiff_float_file | ( | FloatImage::ConstPtr | image, |
std::string const & | filename | ||
) |
Writes a 32bit float TIFF to file.
Supports any number of channels. May throw util::FileException and util::Exception.
Definition at line 933 of file image_io.cc.
mve::Image< T >::Ptr mve::image::sobel_edge | ( | typename mve::Image< T >::ConstPtr | img | ) |
Implementation of the Sobel operator.
For details, see http://en.wikipedia.org/wiki/Sobel_operator For byte images, the operation can lead to clipped values. Likewise for floating point images, it leads to values >1.
Definition at line 1440 of file image_tools.h.
Image< T >::Ptr mve::image::subtract | ( | typename Image< T >::ConstPtr | i1, |
typename Image< T >::ConstPtr | i2 | ||
) |
Subtracts two images to create the signed difference between the values.
This does not work for unsigned image types, use image difference instead.
Definition at line 1489 of file image_tools.h.
void mve::image::tiff_error_handler | ( | char const * | , |
char const * | fmt, | ||
va_list | ap | ||
) |
Definition at line 631 of file image_io.cc.
Image< DST >::Ptr mve::image::type_to_type_image | ( | typename Image< SRC >::ConstPtr | image | ) |
Generic conversion between image types without scaling or clamping.
This is useful to convert between float and double.
Definition at line 488 of file image_tools.h.