Interpolation.h
Go to the documentation of this file.
1#ifndef SHARK_CORE_IMAGES_INTERPOLATION_H
2#define SHARK_CORE_IMAGES_INTERPOLATION_H
3
4#include <shark/LinAlg/Base.h>
5#include <shark/Core/Shark.h>
7#ifdef SHARK_USE_OPENCL
9#endif
10namespace shark{
11enum class Interpolation{
12 Spline
13};
14
15/// \brief Performs interpolation of an image at a set of evaluation points.
16///
17/// Uses the chosen interpolation method to compute the interpolated values at a given point (y,x)
18/// (y,x)-coordinates are encoded such that (0,0) maps to the (0,0) pixel and (1,1) maps to (height, width )
19/// in the image.
20///
21/// The method can interpolate a batch of images at the same time.
22/// For batch-processing, either all images are interpolated with the same points,
23/// in which case points.size1() = pointsPerImage or each image uses its own set of points.
24template<class T, class Device>
26 blas::dense_matrix_adaptor<T const, blas::row_major, blas::continuous_dense_tag, Device> images,
27 Shape const& shape,
28 Interpolation method,
29 blas::dense_matrix_adaptor<T const, blas::row_major, blas::continuous_dense_tag, Device> points,
30 std::size_t pointsPerImage,
31 blas::dense_matrix_adaptor<T, blas::row_major, blas::continuous_dense_tag, Device> values
32){
33 if(method == Interpolation::Spline){
34 image::splineInterpolation2D(images, shape, points, pointsPerImage, values);
35 }
36}
37
38/// \brief Performs interpolation of an image at a set of evaluation points. as well as the derivative wrt the point coordinates.
39///
40/// Uses the chosen interpolation method to compute the interpolated values at a given point (y,x)
41/// (x,x)-coordinates are encoded such that (0,0) maps to the (0,0) pixel and (1,1) maps to (height, width)
42/// in the image.
43///
44/// The method can interpolate a batch of images at the same time.
45/// For batch-processing, either all images are interpolated with the same points,
46/// in which case points.size1() = pointsPerImage or each image uses its own set of points.
47template<class T, class Device>
49 blas::dense_matrix_adaptor<T const, blas::row_major, blas::continuous_dense_tag, Device> images,
50 Shape const& shape,
51 Interpolation method,
52 blas::dense_matrix_adaptor<T const, blas::row_major, blas::continuous_dense_tag, Device> points,
53 std::size_t pointsPerImage,
54 blas::dense_matrix_adaptor<T, blas::row_major, blas::continuous_dense_tag, Device> values,
55 blas::dense_matrix_adaptor<T, blas::row_major, blas::continuous_dense_tag, Device> valuesdx,
56 blas::dense_matrix_adaptor<T, blas::row_major, blas::continuous_dense_tag, Device> valuesdy
57){
58 if(method == Interpolation::Spline){
59 image::splineInterpolation2D(images, shape, points, pointsPerImage, values, valuesdx, valuesdy);
60 }
61}
62
63/// \brief Computes the chain role of the derivative of the chosen interpolation method wrt the interpolated image
64///
65/// This method does n
66template<class T, class Device>
68 blas::dense_matrix_adaptor<T const, blas::row_major, blas::continuous_dense_tag, Device> images,
69 Shape const& shape,
70 Interpolation method,
71 blas::dense_matrix_adaptor<T const, blas::row_major, blas::continuous_dense_tag, Device> imageDerivatives,
72 blas::dense_matrix_adaptor<T const, blas::row_major, blas::continuous_dense_tag, Device> points,
73 std::size_t pointsPerImage,
74 blas::dense_matrix_adaptor<T, blas::row_major, blas::continuous_dense_tag, Device> derivatives
75){
76 if(method == Interpolation::Spline){
77 image::splineInterpolation2DDerivative(imageDerivatives, shape, points, pointsPerImage, derivatives);
78 }
79 (void) images;
80}
81}
82
83#endif