 |
AliceVision
Photogrammetric Computer Vision Framework
|
10 #include <aliceVision/numeric/numeric.hpp>
11 #include <aliceVision/image/pixelTypes.hpp>
26 class Image :
public Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
30 typedef Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> Base;
36 inline Image() { Base::resize(0, 0); }
67 : Base(std::move(src))
84 virtual ~Image() =
default;
110 inline int width()
const {
return static_cast<int>(Base::cols()); }
116 inline int height()
const {
return static_cast<int>(Base::rows()); }
132 return static_cast<unsigned long long int>(
width()) *
static_cast<unsigned long long int>(
height()) *
133 static_cast<unsigned long long int>(
depth());
148 inline const T&
operator()(
int y,
int x)
const {
return Base::operator()(y, x); }
156 inline T&
operator()(
int y,
int x) {
return Base::operator()(y, x); }
158 inline const T&
operator()(
int i)
const {
return Base::operator()(i); }
159 inline T&
operator()(
int i) {
return Base::operator()(i); }
165 inline const Base&
getMat()
const {
return (*
this); }
166 inline Base&
getMat() {
return (*
this); }
178 inline bool contains(
int y,
int x)
const {
return 0 <= x && x < Base::cols() && 0 <= y && y < Base::rows(); }
187 template<
typename T1>
197 template<
typename T1>
200 template<
class UnaryFunction>
201 bool perPixelOperation(UnaryFunction f)
203 for (
auto row : this->rowwise())
205 std::transform(row.begin(), row.end(), row.begin(), f);
222 template<
typename T1>
225 return Image<T1>(imgA.Image<T1>::
operator+(imgB));
235 template<
typename T1>
238 return Image<T1>(imgA.Image<T1>::
operator-(imgB));
242 T getInterpolateColor(
const Image<T>& img,
double y,
double x)
244 const int xp = std::min(
static_cast<int>(x), img.width() - 2);
245 const int yp = std::min(
static_cast<int>(y), img.height() - 2);
248 const float ui = x -
static_cast<float>(xp);
249 const float vi = y -
static_cast<float>(yp);
251 const T lu = img(yp, xp);
252 const T ru = img(yp, (xp + 1));
253 const T rd = img((yp + 1), (xp + 1));
254 const T ld = img((yp + 1), xp);
257 const T u = lu + (ru - lu) * ui;
258 const T d = ld + (rd - ld) * ui;
259 const T out = u + (d - u) * vi;
virtual ~Image()=default
destructor
Image(const Base &I)
Copy constructor.
Definition: Image.hpp:58
RGBA templated pixel type.
Definition: pixelTypes.hpp:179
Image(int width, int height, bool fInit=false, const T val=T())
Full constructor.
Definition: Image.hpp:45
const Base & getMat() const
Get low level access to the internal pixel data.
Definition: Image.hpp:165
Definition: checkerDetector.cpp:32
Image & operator=(const Base &I)
Assignment operator.
Definition: Image.hpp:75
T & operator()(int y, int x)
random pixel access
Definition: Image.hpp:156
Image(Base &&src)
Move constructor.
Definition: Image.hpp:66
Definition: ImageDescriber_AKAZE_OCV.hpp:21
friend Image< T1 > operator+(const Image< T1 > &imgA, const Image< T1 > &imgB)
Pixelwise addition of two images.
Definition: Image.hpp:223
int width() const
Retrieve the width of the image.
Definition: Image.hpp:110
Definition: pixelTypes.hpp:359
friend Image< T1 > operator-(const Image< T1 > &imgA, const Image< T1 > &imgB)
Pixelwise subtraction of two images.
Definition: Image.hpp:236
int height() const
Retrieve the height of the image.
Definition: Image.hpp:116
bool contains(int y, int x) const
Tell if a point is inside the image.
Definition: Image.hpp:178
void resize(int width, int height, bool fInit=true, const T val=T())
Change geometry of image.
Definition: Image.hpp:95
int depth() const
Return the depth in byte of the pixel.
Definition: Image.hpp:123
Image()
Default constructor.
Definition: Image.hpp:36
int channels() const
Return the number of channels.
Definition: Image.hpp:140
const T & operator()(int y, int x) const
constant random pixel access
Definition: Image.hpp:148
unsigned long long int memorySize() const
Retrieve the size in byte of the image.
Definition: Image.hpp:130