ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
IPPImage.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 #pragma once
8 
9 #ifdef WITH_IPP
10 // Not available for Remap
11 // Auto-enable multi-threaded implementations
12 // #define IPP_ENABLED_THREADING_LAYER_REDEFINITIONS 1
13 #define IPP_CALL(ipp_function, ...) ipp_function(__VA_ARGS__);
14 
15 #if IPP_VERSION_INT < \
16  20211000 // macOS IPP v2021.9.11 uses old directory layout
17 #include <iw++/iw_core.hpp>
18 #else // Linux and Windows IPP v2021.10+ uses new directory layout
19 #include <ipp/iw++/iw_core.hpp>
20 #endif
21 
22 #include "cloudViewer/core/Dtype.h"
25 
26 namespace cloudViewer {
27 namespace t {
28 namespace geometry {
29 namespace ipp {
30 
31 inline ::ipp::IppDataType ToIppDataType(core::Dtype dtype) {
32  if (dtype == core::UInt8 || dtype == core::Bool) {
33  return ipp8u;
34  } else if (dtype == core::UInt16) {
35  return ipp16u;
36  } else if (dtype == core::Int16) {
37  return ipp16s;
38  } else if (dtype == core::Int32) {
39  return ipp32s;
40  } else if (dtype == core::Int64) {
41  return ipp64s;
42  } else if (dtype == core::Float32) {
43  return ipp32f;
44  } else if (dtype == core::Float64) {
45  return ipp64f;
46  } else {
47  return ippUndef;
48  }
49 }
50 
51 void To(const core::Tensor &src_im,
52  core::Tensor &dst_im,
53  double scale,
54  double offset);
55 
56 void RGBToGray(const core::Tensor &src_im, core::Tensor &dst_im);
57 
58 void Dilate(const core::Tensor &srcim, core::Tensor &dstim, int kernel_size);
59 
60 void Resize(const core::Tensor &srcim,
61  core::Tensor &dstim,
62  t::geometry::Image::InterpType interp_type);
63 
64 void Filter(const core::Tensor &srcim,
65  core::Tensor &dstim,
66  const core::Tensor &kernel);
67 
68 void FilterBilateral(const core::Tensor &srcim,
69  core::Tensor &dstim,
70  int kernel_size,
71  float value_sigma,
72  float distance_sigma);
73 
74 void FilterGaussian(const core::Tensor &srcim,
75  core::Tensor &dstim,
76  int kernel_size,
77  float sigma);
78 
79 void FilterSobel(const core::Tensor &srcim,
80  core::Tensor &dstim_dx,
81  core::Tensor &dstim_dy,
82  int kernel_size);
83 
84 void Remap(const core::Tensor &src_im, /*{Ws, Hs, C}*/
85  const core::Tensor &dst2src_xmap, /*{Wd, Hd}, float*/
86  const core::Tensor &dst2src_ymap, /*{Wd, Hd, 2}, float*/
87  core::Tensor &dst_im, /*{Wd, Hd, 2}*/
88  Image::InterpType interp_type);
89 
90 } // namespace ipp
91 } // namespace geometry
92 } // namespace t
93 } // namespace cloudViewer
94 
95 #else
96 #define IPP_CALL(ipp_function, ...) \
97  utility::LogError("Not built with IPP-IW, cannot call " #ipp_function);
98 #endif // WITH_IPP
cloudViewer
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
cloudViewer::core::Tensor::Ones
static Tensor Ones(const SizeVector &shape, Dtype dtype, const Device &device=Device("CPU:0"))
Create a tensor fill with ones.
Definition: Tensor.cpp:412
cloudViewer::core::Tensor::GetDtype
Dtype GetDtype() const
Definition: Tensor.h:1164
ShapeUtil.h
cloudViewer::core::UInt16
const Dtype UInt16
Definition: Dtype.cpp:49
cloudViewer::t::geometry::Image::InterpType::Nearest
@ Nearest
Nearest neighbors interpolation.
cloudViewer::core::Int16
const Dtype Int16
Definition: Dtype.cpp:45
cloudViewer::core::Tensor::GetShape
SizeVector GetShape() const
Definition: Tensor.h:1127
cloudViewer::t::geometry::ipp::Resize
void Resize(const core::Tensor &src_im, core::Tensor &dst_im, Image::InterpType interp_type)
Definition: IPPImage.cpp:94
offset
int offset
Definition: FileIOFactory.cpp:135
core::Tensor
cloudViewer::core::Tensor::Neg_
Tensor Neg_()
Element-wise negation of a tensor, in-place.
Definition: Tensor.cpp:1335
cloudViewer::t::geometry::ipp::FilterGaussian
void FilterGaussian(const core::Tensor &src_im, core::Tensor &dst_im, int kernel_size, float sigma)
Definition: IPPImage.cpp:233
cloudViewer::core::Dtype::ByteSize
int64_t ByteSize() const
Definition: Dtype.h:59
cloudViewer::t::geometry::ipp::To
void To(const core::Tensor &src_im, core::Tensor &dst_im, double scale, double offset)
Definition: IPPImage.cpp:42
cloudViewer::t::geometry::ipp::RGBToGray
void RGBToGray(const core::Tensor &src_im, core::Tensor &dst_im)
Definition: IPPImage.cpp:71
cloudViewer::t::geometry::ipp::FilterSobel
void FilterSobel(const core::Tensor &src_im, core::Tensor &dst_im_dx, core::Tensor &dst_im_dy, int kernel_size)
Definition: IPPImage.cpp:261
cloudViewer::t::geometry::ipp::Remap
void Remap(const core::Tensor &src_im, const core::Tensor &dst2src_xmap, const core::Tensor &dst2src_ymap, core::Tensor &dst_im, Image::InterpType interp_type)
Definition: IPPImage.cpp:311
IPPImage.h
e
const double * e
Definition: essential_matrix_poly.h:10
cloudViewer::core::Int32
const Dtype Int32
Definition: Dtype.cpp:46
cloudViewer::t::geometry::Image::InterpType
InterpType
Image interpolation algorithms.
Definition: Image.h:178
cloudViewer::t::geometry::Image::InterpType::Lanczos
@ Lanczos
Lanczos filter interpolation.
Dispatch.h
cloudViewer::core::UInt8
const Dtype UInt8
Definition: Dtype.cpp:48
cloudViewer::core::Bool
const Dtype Bool
Definition: Dtype.cpp:52
cloudViewer::core::Dtype::ToString
std::string ToString() const
Definition: Dtype.h:65
cloudViewer::core::Float64
const Dtype Float64
Definition: Dtype.cpp:43
cloudViewer::core::Tensor::GetDevice
Device GetDevice() const override
Definition: Tensor.cpp:1435
cloudViewer::t::geometry::ipp::Filter
void Filter(const core::Tensor &src_im, core::Tensor &dst_im, const core::Tensor &kernel)
Definition: IPPImage.cpp:170
cloudViewer::core::Float32
const Dtype Float32
Definition: Dtype.cpp:42
cloudViewer::core::SizeVector
Definition: SizeVector.h:70
LogError
#define LogError(...)
Definition: Logging.h:60
cloudViewer::t::geometry::Image::InterpType::Cubic
@ Cubic
Bicubic interpolation.
Image.h
Tensor.h
cloudViewer::t::geometry::ipp::Dilate
void Dilate(const core::Tensor &src_im, core::Tensor &dst_im, int kernel_size)
Definition: IPPImage.cpp:133
cloudViewer::core::Tensor::GetStride
int64_t GetStride(int64_t dim) const
Definition: Tensor.h:1139
cloudViewer::t::geometry::ipp::FilterBilateral
void FilterBilateral(const core::Tensor &src_im, core::Tensor &dst_im, int kernel_size, float value_sigma, float distance_sigma)
Definition: IPPImage.cpp:202
cloudViewer::t::geometry::Image::InterpType::Super
@ Super
Super sampling interpolation (only downsample).
cloudViewer::t::geometry::Image::InterpType::Linear
@ Linear
Bilinear interpolation.
cloudViewer::core::Int64
const Dtype Int64
Definition: Dtype.cpp:47
Dtype.h
cloudViewer::core::Tensor::GetDataPtr
T * GetDataPtr()
Definition: Tensor.h:1144