ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
warp.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include "base/camera.h"
11 #include "util/alignment.h"
12 #include "util/bitmap.h"
13 
14 namespace colmap {
15 
16 // Warp source image to target image by projecting the pixels of the target
17 // image up to infinity and projecting it down into the source image
18 // (i.e. an inverse mapping). The function allocates the target image.
19 void WarpImageBetweenCameras(const Camera& source_camera,
20  const Camera& target_camera,
21  const Bitmap& source_image,
22  Bitmap* target_image);
23 
24 // Warp an image with the given homography, where H defines the pixel mapping
25 // from the target to source image. Note that the pixel centers are assumed to
26 // have coordinates (0.5, 0.5).
27 void WarpImageWithHomography(const Eigen::Matrix3d& H,
28  const Bitmap& source_image,
29  Bitmap* target_image);
30 
31 // First, warp source image to target image by projecting the pixels of the
32 // target image up to infinity and projecting it down into the source image
33 // (i.e. an inverse mapping). Second, warp the coordinates from the first
34 // warping with the given homography. The function allocates the target image.
35 void WarpImageWithHomographyBetweenCameras(const Eigen::Matrix3d& H,
36  const Camera& source_camera,
37  const Camera& target_camera,
38  const Bitmap& source_image,
39  Bitmap* target_image);
40 
41 // Resample row-major image using bilinear interpolation.
42 void ResampleImageBilinear(const float* data,
43  const int rows,
44  const int cols,
45  const int new_rows,
46  const int new_cols,
47  float* resampled);
48 
49 // Smooth row-major image using a Gaussian filter kernel.
50 void SmoothImage(const float* data,
51  const int rows,
52  const int cols,
53  const float sigma_r,
54  const float sigma_c,
55  float* smoothed);
56 
57 // Downsample row-major image by first smoothing and then resampling.
58 void DownsampleImage(const float* data,
59  const int rows,
60  const int cols,
61  const int new_rows,
62  const int new_cols,
63  float* downsampled);
64 
65 } // namespace colmap
warp.h
colmap::Bitmap::Rescale
void Rescale(const int new_width, const int new_height, const FREE_IMAGE_FILTER filter=FILTER_BILINEAR)
Definition: bitmap.cc:581
colmap::VisibilityPyramid::SetPoint
void SetPoint(const double x, const double y)
Definition: visibility_pyramid.cc:52
x
normal_z x
Definition: my_point_types.h:165
visibility_pyramid.h
colmap::Bitmap::IsRGB
bool IsRGB() const
Definition: bitmap.h:261
data
GraphType data
Definition: graph_cut.cc:138
bitmap.h
colmap::Camera::WorldToImage
Eigen::Vector2d WorldToImage(const Eigen::Vector2d &world_point) const
Definition: camera.cc:230
colmap::Bitmap::SetPixel
bool SetPixel(const int x, const int y, const BitmapColor< uint8_t > &color)
Definition: bitmap.cc:199
alignment.h
colmap::Bitmap
Definition: bitmap.h:51
colmap::VisibilityPyramid::NumLevels
size_t NumLevels() const
Definition: visibility_pyramid.h:69
colmap::Bitmap::Allocate
bool Allocate(const int width, const int height, const bool as_rgb)
Definition: bitmap.cc:104
color
math::float4 color
Definition: LineSetBuffers.cpp:46
testing.h
colmap::WarpImageBetweenCameras
void WarpImageBetweenCameras(const Camera &source_camera, const Camera &target_camera, const Bitmap &source_image, Bitmap *target_image)
Definition: warp.cc:51
colmap::Camera::ImageToWorld
Eigen::Vector2d ImageToWorld(const Eigen::Vector2d &image_point) const
Definition: camera.cc:219
y
normal_z y
Definition: my_point_types.h:168
colmap::Bitmap::Width
int Width() const
Definition: bitmap.h:249
colmap::DownsampleImage
void DownsampleImage(const float *data, const int rows, const int cols, const int new_rows, const int new_cols, float *downsampled)
Definition: warp.cc:226
colmap::VisibilityPyramid::ResetPoint
void ResetPoint(const double x, const double y)
Definition: visibility_pyramid.cc:74
colmap::Bitmap::Height
int Height() const
Definition: bitmap.h:250
colmap::VisibilityPyramid::MaxScore
size_t MaxScore() const
Definition: visibility_pyramid.h:77
colmap::Camera::Width
size_t Width() const
Definition: camera.h:160
colmap::Bitmap::InterpolateBilinear
bool InterpolateBilinear(const double x, const double y, BitmapColor< float > *color) const
Definition: bitmap.cc:248
colmap::VisibilityPyramid
Definition: visibility_pyramid.h:28
cloudViewer::utility::floor
MiniVec< float, N > floor(const MiniVec< float, N > &a)
Definition: MiniVec.h:75
colmap::BitmapColor
Definition: bitmap.h:30
colmap::WarpImageWithHomographyBetweenCameras
void WarpImageWithHomographyBetweenCameras(const Eigen::Matrix3d &H, const Camera &source_camera, const Camera &target_camera, const Bitmap &source_image, Bitmap *target_image)
Definition: warp.cc:124
colmap::VisibilityPyramid::Width
size_t Width() const
Definition: visibility_pyramid.h:71
camera.h
colmap::Camera::Rescale
void Rescale(const double scale)
Definition: camera.cc:237
colmap::WarpImageWithHomography
void WarpImageWithHomography(const Eigen::Matrix3d &H, const Bitmap &source_image, Bitmap *target_image)
Definition: warp.cc:98
colmap::SmoothImage
void SmoothImage(const float *data, const int rows, const int cols, const float sigma_r, const float sigma_c, float *smoothed)
Definition: warp.cc:215
logging.h
colmap
Definition: AutomaticReconstructionController.h:17
colmap::Camera::Height
size_t Height() const
Definition: camera.h:162
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(TestDefault)
Definition: visibility_pyramid_test.cc:39
colmap::ResampleImageBilinear
void ResampleImageBilinear(const float *data, const int rows, const int cols, const int new_rows, const int new_cols, float *resampled)
Definition: warp.cc:174
colmap::VisibilityPyramid::Height
size_t Height() const
Definition: visibility_pyramid.h:73
colmap::Camera
Definition: camera.h:20
colmap::VisibilityPyramid::Score
size_t Score() const
Definition: visibility_pyramid.h:75