MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
mvs_tools.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015, Ronny Klowsky, Simon Fuhrmann
3 * TU Darmstadt - Graphics, Capture and Massively Parallel Computing
4 * All rights reserved.
5 *
6 * This software may be modified and distributed under the terms
7 * of the BSD 3-Clause license. See the LICENSE.txt file for details.
8 */
9
10#ifndef DMRECON_MVS_TOOLS_H
11#define DMRECON_MVS_TOOLS_H
12
13#include <iostream>
14
15#include "math/matrix.h"
16#include "math/vector.h"
17#include "mve/image.h"
18#include "dmrecon/defines.h"
19#include "dmrecon/single_view.h"
20
22
24void colAndExactDeriv(mve::ByteImage const& img,
25 PixelCoords const& imgPos, PixelCoords const& gradDir,
26 Samples& color, Samples& deriv);
27
29void getXYZColorAtPix(mve::ByteImage const& img,
30 std::vector<math::Vec2i> const& imgPos, Samples* color);
31
33void getXYZColorAtPos(mve::ByteImage const& img,
34 PixelCoords const& imgPos, Samples* color);
35
38
41float parallaxToWeight(float p);
42
43/* ------------------------- Implementation ----------------------- */
44
45inline float
47{
48 math::Vec3f dir1 = (p - v1->camPos).normalized();
49 math::Vec3f dir2 = (p - v2->camPos).normalized();
50 float dp = std::max(std::min(dir1.dot(dir2), 1.f), -1.f);
51 float plx = std::acos(dp) * 180.f / pi;
52 return plx;
53}
54
55inline float
57{
58 if (p < 0.f || p > 180.f) {
59 std::cerr << "ERROR: invalid parallax value." << std::endl;
60 return 0.f;
61 }
62 float sigma;
63 if (p <= 20.f)
64 sigma = 5.f;
65 else
66 sigma = 15.f;
67 float mean = 20.f;
68 return exp(- sqr(p - mean) / (2 * sigma * sigma));
69}
70
72
73#endif
Vector class for arbitrary dimensions and types.
Definition vector.h:87
T dot(Vector< T, N > const &other) const
Dot (or scalar) product between self and another vector.
Definition vector.h:542
Multi-channel image class of arbitrary but homogenous data type.
Definition image.h:40
std::shared_ptr< SingleView > Ptr
Definition single_view.h:31
#define MVS_NAMESPACE_BEGIN
Definition defines.h:18
#define MVS_NAMESPACE_END
Definition defines.h:19
void colAndExactDeriv(mve::ByteImage const &img, PixelCoords const &imgPos, PixelCoords const &gradDir, Samples &color, Samples &deriv)
interpolate color and derivative at given sample positions
Definition mvs_tools.cc:98
void getXYZColorAtPos(mve::ByteImage const &img, PixelCoords const &imgPos, Samples *color)
interpolate only color at given sample positions
Definition mvs_tools.cc:169
float parallax(math::Vec3f p, mvs::SingleView::Ptr v1, mvs::SingleView::Ptr v2)
Computes the parallax between two views with respect to some 3D point p.
Definition mvs_tools.h:46
float parallaxToWeight(float p)
Turns a parallax value (0 <= p <= 180) into a weight according to a bilateral Gaussian (see [Furukawa...
Definition mvs_tools.h:56
const T sqr(const T &a)
Definition defines.h:31
void getXYZColorAtPix(mve::ByteImage const &img, std::vector< math::Vec2i > const &imgPos, Samples *color)
get color at given pixel positions (no interpolation)
Definition mvs_tools.cc:150
const float pi
Definition defines.h:28