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
GraphType data
Definition: graph_cut.cc:138
void WarpImageBetweenCameras(const Camera &source_camera, const Camera &target_camera, const Bitmap &source_image, Bitmap *target_image)
Definition: warp.cc:51
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
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
void WarpImageWithHomography(const Eigen::Matrix3d &H, const Bitmap &source_image, Bitmap *target_image)
Definition: warp.cc:98
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
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