![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
The Image class stores image with customizable rows, cols, channels, dtype and device. More...
#include <Image.h>


Public Types | |
| enum class | InterpType { Nearest = 0 , Linear = 1 , Cubic = 2 , Lanczos = 3 , Super = 4 } |
| Image interpolation algorithms. More... | |
Public Types inherited from cloudViewer::t::geometry::Geometry | |
| enum class | GeometryType { Unspecified = 0 , PointCloud = 1 , VoxelGrid = 2 , Octree = 3 , LineSet = 4 , MeshBase = 5 , TriangleMesh = 6 , HalfEdgeTriangleMesh = 7 , Image = 8 , RGBDImage = 9 , TetraMesh = 10 , OrientedBoundingBox = 11 , AxisAlignedBoundingBox = 12 } |
| Specifies possible geometry types. More... | |
Public Member Functions | |
| Image (int64_t rows=0, int64_t cols=0, int64_t channels=1, core::Dtype dtype=core::Float32, const core::Device &device=core::Device("CPU:0")) | |
| Constructor for image. More... | |
| Image (const core::Tensor &tensor) | |
| Construct from a tensor. The tensor won't be copied and memory will be shared. More... | |
| virtual | ~Image () override |
| Image & | Clear () override |
| Clear image contents by resetting the rows and cols to 0, while keeping channels, dtype and device unchanged. More... | |
| bool | IsEmpty () const override |
| Returns true if rows * cols * channels == 0. More... | |
| Image & | Reset (int64_t rows=0, int64_t cols=0, int64_t channels=1, core::Dtype dtype=core::Float32, const core::Device &device=core::Device("CPU:0")) |
| Reinitialize image with new parameters. More... | |
| int64_t | GetRows () const |
| Get the number of rows of the image. More... | |
| int64_t | GetCols () const |
| Get the number of columns of the image. More... | |
| int64_t | GetChannels () const |
| Get the number of channels of the image. More... | |
| core::Dtype | GetDtype () const |
| Get dtype of the image. More... | |
| core::Device | GetDevice () const override |
| Get device of the image. More... | |
| core::Tensor | At (int64_t r, int64_t c) const |
| Get pixel(s) in the image. More... | |
| core::Tensor | At (int64_t r, int64_t c, int64_t ch) const |
| Get pixel(s) in the image. Returns a tensor with shape {}. More... | |
| void * | GetDataPtr () |
| Get raw buffer of the Image data. More... | |
| const void * | GetDataPtr () const |
| Get raw buffer of the Image data. More... | |
| core::Tensor | AsTensor () const |
| Returns the underlying Tensor of the Image. More... | |
| Image | To (const core::Device &device, bool copy=false) const |
| Transfer the image to a specified device. More... | |
| Image | CPU () const |
| Backward-compatible convenience method to obtain a CPU-resident copy. More... | |
| Image | Clone () const |
| Returns copy of the image on the same device. More... | |
| Image | To (core::Dtype dtype, bool copy=false, utility::optional< double > scale=utility::nullopt, double offset=0.0) const |
Returns an Image with the specified dtype. More... | |
| Image & | LinearTransform (double scale=1.0, double offset=0.0) |
| Function to linearly transform pixel intensities in place. More... | |
| Image | RGBToGray () const |
| Converts a 3-channel RGB image to a new 1-channel Grayscale image. More... | |
| Image | Resize (float sampling_rate=0.5f, InterpType interp_type=InterpType::Nearest) const |
| Return a new image after resizing with specified interpolation type. More... | |
| Image | Dilate (int kernel_size=3) const |
| Return a new image after performing morphological dilation. More... | |
| Image | Filter (const core::Tensor &kernel) const |
| Return a new image after filtering with the given kernel. More... | |
| Image | FilterBilateral (int kernel_size=3, float value_sigma=20.0f, float distance_sigma=10.0f) const |
| Return a new image after bilateral filtering. More... | |
| Image | FilterGaussian (int kernel_size=3, float sigma=1.0f) const |
| Return a new image after Gaussian filtering. More... | |
| std::pair< Image, Image > | FilterSobel (int kernel_size=3) const |
| Return a pair of new gradient images (dx, dy) after Sobel filtering. More... | |
| Image | PyrDown () const |
| Return a new downsampled image with pyramid downsampling. More... | |
| Image | PyrDownDepth (float diff_threshold, float invalid_fill=0.f) const |
| Edge and invalid value preserving downsampling by 2 specifically for depth images. More... | |
| Image | ClipTransform (float scale, float min_value, float max_value, float clip_fill=0.0f) const |
| Return new image after scaling and clipping image values. More... | |
| Image | CreateVertexMap (const core::Tensor &intrinsics, float invalid_fill=0.0f) |
| Create a vertex map from a depth image using unprojection. More... | |
| Image | CreateNormalMap (float invalid_fill=0.0f) |
| Create a normal map from a vertex map. More... | |
| Image | ColorizeDepth (float scale, float min_value, float max_value) |
| Colorize an input depth image (with Dtype UInt16 or Float32). More... | |
| core::Tensor | GetMinBound () const |
| Compute min 2D coordinates for the data (always {0, 0}). More... | |
| core::Tensor | GetMaxBound () const |
| Compute max 2D coordinates for the data ({rows, cols}). More... | |
| cloudViewer::geometry::Image | ToLegacy () const |
| Convert to legacy Image type. More... | |
| std::string | ToString () const |
| Text description. More... | |
Public Member Functions inherited from cloudViewer::t::geometry::Geometry | |
| virtual | ~Geometry () |
| GeometryType | GetGeometryType () const |
| Returns one of registered geometry types. More... | |
| int | Dimension () const |
| Returns whether the geometry is 2D or 3D. More... | |
| std::string | GetName () const |
| void | SetName (const std::string &name) |
Public Member Functions inherited from cloudViewer::core::IsDevice | |
| IsDevice ()=default | |
| virtual | ~IsDevice ()=default |
| bool | IsCPU () const |
| bool | IsCUDA () const |
| bool | IsSYCL () const |
Static Public Member Functions | |
| static Image | FromLegacy (const cloudViewer::geometry::Image &image_legacy, const core::Device &Device=core::Device("CPU:0")) |
| Create from a legacy CloudViewer Image. More... | |
Static Public Attributes | |
| static constexpr bool | HAVE_IPP = false |
| Do we use IPP for accelerating image processing operations? More... | |
Protected Attributes | |
| core::Tensor | data_ |
Additional Inherited Members | |
Protected Member Functions inherited from cloudViewer::t::geometry::Geometry | |
| Geometry (GeometryType type, int dimension) | |
| Parameterized Constructor. More... | |
The Image class stores image with customizable rows, cols, channels, dtype and device.
|
strong |
| cloudViewer::t::geometry::Image::Image | ( | int64_t | rows = 0, |
| int64_t | cols = 0, |
||
| int64_t | channels = 1, |
||
| core::Dtype | dtype = core::Float32, |
||
| const core::Device & | device = core::Device("CPU:0") |
||
| ) |
Constructor for image.
Row-major storage is used, similar to OpenCV. Use (row, col, channel) indexing order for image creation and accessing. In general, (r, c, ch) are the preferred variable names for consistency, and avoid using width, height, u, v, x, y for coordinates.
| rows | Number of rows of the image, i.e. image height. rows must be non-negative. |
| cols | Number of columns of the image, i.e. image width. cols must be non-negative. |
| channels | Number of channels of the image. E.g. for RGB image, channels == 3; for grayscale image, channels == 1. channels must be greater than 0. |
| dtype | Data type of the image. |
| device | Device where the image is stored. |
Definition at line 31 of file Image.cpp.
References Reset().
Referenced by FromLegacy(), Resize(), and To().
| cloudViewer::t::geometry::Image::Image | ( | const core::Tensor & | tensor | ) |
Construct from a tensor. The tensor won't be copied and memory will be shared.
| tensor | Tensor of the image. The tensor must be contiguous. The tensor must be 2D (rows, cols) or 3D (rows, cols, channels). |
Definition at line 40 of file Image.cpp.
References cloudViewer::core::shape_util::Concat(), data_, cloudViewer::core::Tensor::GetShape(), cloudViewer::core::Tensor::IsContiguous(), LogError, cloudViewer::core::Tensor::NumDims(), cloudViewer::core::Tensor::Reshape(), and cloudViewer::core::SizeVector::ToString().
|
inlineoverridevirtual |
|
inline |
Returns the underlying Tensor of the Image.
Definition at line 124 of file Image.h.
References data_.
Referenced by ClipTransform(), ColorizeDepth(), cloudViewer::t::pipelines::odometry::ComputeOdometryInformationMatrix(), cloudViewer::t::pipelines::odometry::ComputeOdometryResultPointToPlane(), cloudViewer::t::geometry::PointCloud::CreateFromDepthImage(), cloudViewer::t::geometry::PointCloud::CreateFromRGBDImage(), CreateNormalMap(), CreateVertexMap(), cloudViewer::t::geometry::VoxelBlockGrid::GetUniqueBlockCoordinates(), cloudViewer::t::geometry::VoxelBlockGrid::Integrate(), cloudViewer::t::geometry::pybind_image(), PyrDownDepth(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScale(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleHybrid(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleIntensity(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScalePointToPlane(), cloudViewer::t::geometry::TriangleMesh::SamplePointsUniformly(), cloudViewer::t::pipelines::slam::Frame::SetDataFromImage(), and cloudViewer::t::io::DepthNoiseSimulator::Simulate().
|
inline |
Get pixel(s) in the image.
If channels == 1, returns a tensor with shape {}, otherwise returns a tensor with shape {channels,}. The returned tensor is a slice of the image's tensor, so when modifying the slice, the original tensor will also be modified.
Definition at line 104 of file Image.h.
References data_, and GetChannels().
|
inline |
|
inlineoverridevirtual |
Clear image contents by resetting the rows and cols to 0, while keeping channels, dtype and device unchanged.
Implements cloudViewer::t::geometry::Geometry.
Definition at line 65 of file Image.h.
References data_, GetChannels(), GetDevice(), and GetDtype().
Referenced by cloudViewer::t::geometry::RGBDImage::Clear(), and cloudViewer::t::geometry::pybind_image().
| Image cloudViewer::t::geometry::Image::ClipTransform | ( | float | scale, |
| float | min_value, | ||
| float | max_value, | ||
| float | clip_fill = 0.0f |
||
| ) | const |
Return new image after scaling and clipping image values.
This is typically used for preprocessing a depth image. Images of shape (rows, cols, channels=1) and Dtypes UInt16 and Float32 are supported. Each pixel will be transformed by
scale min_value ? clip_fill : xmax_value ? clip_fill : xUse INFINITY, NAN or 0.0 (default) for clip_fill.
clip_fill value. Definition at line 417 of file Image.cpp.
References AssertTensorDtypes, AsTensor(), cloudViewer::t::geometry::kernel::image::ClipTransform(), data_, cloudViewer::core::Float32, GetChannels(), GetCols(), cloudViewer::core::Tensor::GetDevice(), GetRows(), LogError, LogWarning, and cloudViewer::core::UInt16.
Referenced by cloudViewer::t::pipelines::odometry::ComputeOdometryInformationMatrix(), cloudViewer::t::pipelines::odometry::ComputeOdometryResultPointToPlane(), cloudViewer::t::geometry::CreatePointCloudWithNormals(), cloudViewer::t::geometry::pybind_image(), and cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScale().
|
inline |
Returns copy of the image on the same device.
Definition at line 143 of file Image.h.
References GetDevice(), and To().
Referenced by cloudViewer::t::geometry::pybind_image().
| Image cloudViewer::t::geometry::Image::ColorizeDepth | ( | float | scale, |
| float | min_value, | ||
| float | max_value | ||
| ) |
Colorize an input depth image (with Dtype UInt16 or Float32).
The image values are divided by scale, then clamped within [min_value, max_value] and finally converted to an RGB image using the Turbo colormap as a lookup table.
Definition at line 482 of file Image.cpp.
References AssertTensorDtypes, AsTensor(), cloudViewer::t::geometry::kernel::image::ColorizeDepth(), data_, cloudViewer::core::Float32, GetChannels(), GetCols(), GetDevice(), GetRows(), LogError, cloudViewer::core::UInt16, and cloudViewer::core::UInt8.
Referenced by cloudViewer::t::geometry::pybind_image().
|
inline |
| Image cloudViewer::t::geometry::Image::CreateNormalMap | ( | float | invalid_fill = 0.0f | ) |
Create a normal map from a vertex map.
The input vertex map image should be of shape (rows, cols, channels=3) and Dtype Float32. This uses a cross product of
and
. The input vertex map is expected to be the output of CreateVertexMap. You may need to start with a filtered depth image (e.g. with FilterBilateral) to obtain good results.
| invalid_fill | Value to fill in for invalid points, and to fill-in if no valid neighbor is found. Use NAN, INFINITY or 0.0 (default). Must be consistent with clip_fill in CreateVertexMap. |
invalid_fill value. Definition at line 467 of file Image.cpp.
References AssertTensorDtype, AsTensor(), cloudViewer::t::geometry::kernel::image::CreateNormalMap(), data_, cloudViewer::core::Float32, GetChannels(), GetCols(), GetDevice(), GetDtype(), GetRows(), and LogError.
Referenced by cloudViewer::t::pipelines::odometry::ComputeOdometryResultPointToPlane(), cloudViewer::t::geometry::pybind_image(), and cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScalePointToPlane().
| Image cloudViewer::t::geometry::Image::CreateVertexMap | ( | const core::Tensor & | intrinsics, |
| float | invalid_fill = 0.0f |
||
| ) |
Create a vertex map from a depth image using unprojection.
The input depth (of shape (rows, cols, channels=1) and Dtype Float32) is expected to be the output of ClipTransform.
| intrinsics | Pinhole camera model of (3, 3) in Float64. |
| invalid_fill | Value to fill in for invalid depths. Use NAN, INFINITY or 0.0 (default). Must be consistent with clip_fill in ClipTransform. |
invalid_fill value. Definition at line 449 of file Image.cpp.
References AssertTensorDtype, AssertTensorShape, AsTensor(), cloudViewer::t::geometry::kernel::image::CreateVertexMap(), data_, cloudViewer::core::Float32, GetChannels(), GetCols(), GetDevice(), GetDtype(), GetRows(), and LogError.
Referenced by cloudViewer::t::pipelines::odometry::ComputeOdometryInformationMatrix(), cloudViewer::t::pipelines::odometry::ComputeOdometryResultPointToPlane(), cloudViewer::t::geometry::pybind_image(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleHybrid(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleIntensity(), and cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScalePointToPlane().
| Image cloudViewer::t::geometry::Image::Dilate | ( | int | kernel_size = 3 | ) | const |
Return a new image after performing morphological dilation.
Supported datatypes are UInt8, UInt16 and Float32 with {1, 3, 4} channels. An 8-connected neighborhood is used to create the dilation mask.
| kernel_size | An odd number >= 3. |
Definition at line 203 of file Image.cpp.
References cloudViewer::core::Bool, count, CUDA_CALL, data_, cloudViewer::t::geometry::ipp::Dilate(), cloudViewer::t::geometry::npp::Dilate(), cloudViewer::core::Tensor::EmptyLike(), cloudViewer::core::Float32, GetChannels(), GetDevice(), GetDtype(), HAVE_IPP, cloudViewer::core::Int32, IPP_CALL, cloudViewer::core::IsDevice::IsCPU(), cloudViewer::core::IsDevice::IsCUDA(), LogError, cloudViewer::core::make_pair(), ToString(), cloudViewer::core::UInt16, and cloudViewer::core::UInt8.
Referenced by cloudViewer::t::geometry::pybind_image().
| Image cloudViewer::t::geometry::Image::Filter | ( | const core::Tensor & | kernel | ) | const |
Return a new image after filtering with the given kernel.
Definition at line 278 of file Image.cpp.
References count, CUDA_CALL, data_, cloudViewer::core::Tensor::EmptyLike(), cloudViewer::t::geometry::npp::Filter(), cloudViewer::t::geometry::ipp::Filter(), cloudViewer::core::Float32, GetChannels(), GetDevice(), GetDtype(), HAVE_IPP, IPP_CALL, cloudViewer::core::IsDevice::IsCPU(), cloudViewer::core::IsDevice::IsCUDA(), LogError, cloudViewer::core::make_pair(), ToString(), cloudViewer::core::UInt16, and cloudViewer::core::UInt8.
Referenced by cloudViewer::t::geometry::pybind_image().
| Image cloudViewer::t::geometry::Image::FilterBilateral | ( | int | kernel_size = 3, |
| float | value_sigma = 20.0f, |
||
| float | distance_sigma = 10.0f |
||
| ) | const |
Return a new image after bilateral filtering.
| value_sigma | Standard deviation for the image content. |
| distance_sigma | Standard deviation for the image pixel positions. |
Note: CPU (IPP) and CUDA (NPP) versions use different algorithms and will give different results:
CPU uses a round kernel (radius = floor(kernel_size / 2)),
while CUDA uses a square kernel (width = kernel_size).
Make sure to tune parameters accordingly.
Definition at line 239 of file Image.cpp.
References count, CUDA_CALL, data_, cloudViewer::core::Tensor::EmptyLike(), cloudViewer::t::geometry::ipp::FilterBilateral(), cloudViewer::t::geometry::npp::FilterBilateral(), cloudViewer::core::Float32, GetChannels(), GetDevice(), GetDtype(), HAVE_IPP, IPP_CALL, cloudViewer::core::IsDevice::IsCPU(), cloudViewer::core::IsDevice::IsCUDA(), LogError, cloudViewer::core::make_pair(), ToString(), cloudViewer::core::UInt16, and cloudViewer::core::UInt8.
Referenced by cloudViewer::t::geometry::pybind_image(), and cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScalePointToPlane().
| Image cloudViewer::t::geometry::Image::FilterGaussian | ( | int | kernel_size = 3, |
| float | sigma = 1.0f |
||
| ) | const |
Return a new image after Gaussian filtering.
| kernel_size | Odd numbers >= 3 are supported. |
| sigma | Standard deviation of the Gaussian distribution. |
Definition at line 309 of file Image.cpp.
References count, CUDA_CALL, data_, cloudViewer::core::Tensor::EmptyLike(), cloudViewer::t::geometry::ipp::FilterGaussian(), cloudViewer::t::geometry::npp::FilterGaussian(), cloudViewer::core::Float32, GetChannels(), GetDevice(), GetDtype(), HAVE_IPP, IPP_CALL, cloudViewer::core::IsDevice::IsCPU(), cloudViewer::core::IsDevice::IsCUDA(), LogError, cloudViewer::core::make_pair(), ToString(), cloudViewer::core::UInt16, and cloudViewer::core::UInt8.
Referenced by cloudViewer::t::geometry::pybind_image(), and PyrDown().
Return a pair of new gradient images (dx, dy) after Sobel filtering.
| kernel_size | Sobel filter kernel size, either 3 or 5. |
Definition at line 345 of file Image.cpp.
References count, CUDA_CALL, data_, cloudViewer::core::Tensor::Empty(), cloudViewer::core::Tensor::EmptyLike(), cloudViewer::t::geometry::ipp::FilterSobel(), cloudViewer::t::geometry::npp::FilterSobel(), cloudViewer::core::Float32, GetChannels(), cloudViewer::core::Tensor::GetDevice(), GetDevice(), GetDtype(), cloudViewer::core::Tensor::GetShape(), HAVE_IPP, cloudViewer::core::Int16, IPP_CALL, cloudViewer::core::IsDevice::IsCPU(), cloudViewer::core::IsDevice::IsCUDA(), LogError, cloudViewer::core::make_pair(), ToString(), and cloudViewer::core::UInt8.
Referenced by cloudViewer::t::geometry::pybind_image(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleHybrid(), and cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleIntensity().
|
static |
Create from a legacy CloudViewer Image.
Definition at line 505 of file Image.cpp.
References cloudViewer::geometry::Image::bytes_per_channel_, cloudViewer::geometry::Image::BytesPerLine(), cloudViewer::geometry::Image::data_, cloudViewer::core::Float32, cloudViewer::geometry::Image::height_, Image(), image, cloudViewer::geometry::Image::IsEmpty(), LogError, cloudViewer::core::MemoryManager::MemcpyFromHost(), cloudViewer::geometry::Image::num_of_channels_, cloudViewer::core::UInt16, cloudViewer::core::UInt8, and cloudViewer::geometry::Image::width_.
Referenced by cloudViewer::t::geometry::TriangleMesh::FromLegacy(), and cloudViewer::t::geometry::pybind_image().
|
inline |
Get the number of channels of the image.
Definition at line 90 of file Image.h.
References data_, and cloudViewer::core::Tensor::GetShape().
Referenced by At(), Clear(), ClipTransform(), ColorizeDepth(), CreateNormalMap(), CreateVertexMap(), Dilate(), Filter(), FilterBilateral(), FilterGaussian(), FilterSobel(), IsEmpty(), cloudViewer::t::geometry::pybind_image(), PyrDownDepth(), Resize(), RGBToGray(), cloudViewer::t::io::DepthNoiseSimulator::Simulate(), To(), ToLegacy(), ToString(), and cloudViewer::t::geometry::RGBDImage::ToString().
|
inline |
Get the number of columns of the image.
Definition at line 87 of file Image.h.
References data_, and cloudViewer::core::Tensor::GetShape().
Referenced by ClipTransform(), ColorizeDepth(), CreateNormalMap(), cloudViewer::t::geometry::CreatePointCloudWithNormals(), CreateVertexMap(), cloudViewer::t::pipelines::slac::ControlGrid::Deform(), GetMaxBound(), cloudViewer::t::geometry::RGBDImage::GetMaxBound(), cloudViewer::t::geometry::VoxelBlockGrid::GetUniqueBlockCoordinates(), IsEmpty(), cloudViewer::t::geometry::pybind_image(), PyrDownDepth(), Resize(), cloudViewer::t::geometry::RGBDImage::RGBDImage(), RGBToGray(), cloudViewer::t::io::DepthNoiseSimulator::Simulate(), To(), ToLegacy(), ToString(), and cloudViewer::t::geometry::RGBDImage::ToString().
|
inline |
Get raw buffer of the Image data.
Definition at line 118 of file Image.h.
References data_, and cloudViewer::core::Tensor::GetDataPtr().
Referenced by cloudViewer::t::geometry::pybind_image().
|
inline |
Get raw buffer of the Image data.
Definition at line 121 of file Image.h.
References data_, and cloudViewer::core::Tensor::GetDataPtr().
|
inlineoverridevirtual |
Get device of the image.
Implements cloudViewer::t::geometry::Geometry.
Definition at line 96 of file Image.h.
References data_, and cloudViewer::core::Tensor::GetDevice().
Referenced by Clear(), Clone(), cloudViewer::t::geometry::RGBDImage::Clone(), ColorizeDepth(), CreateNormalMap(), CreateVertexMap(), Dilate(), Filter(), FilterBilateral(), FilterGaussian(), FilterSobel(), cloudViewer::t::geometry::RGBDImage::GetDevice(), cloudViewer::t::geometry::pybind_image(), PyrDownDepth(), Resize(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScale(), RGBToGray(), To(), ToString(), and cloudViewer::t::geometry::RGBDImage::ToString().
|
inline |
Get dtype of the image.
Definition at line 93 of file Image.h.
References data_, and cloudViewer::core::Tensor::GetDtype().
Referenced by Clear(), CreateNormalMap(), CreateVertexMap(), Dilate(), Filter(), FilterBilateral(), FilterGaussian(), FilterSobel(), LinearTransform(), cloudViewer::t::geometry::pybind_image(), PyrDownDepth(), Resize(), RGBToGray(), cloudViewer::t::io::DepthNoiseSimulator::Simulate(), To(), ToLegacy(), ToString(), and cloudViewer::t::geometry::RGBDImage::ToString().
|
inline |
Compute max 2D coordinates for the data ({rows, cols}).
Definition at line 320 of file Image.h.
References GetCols(), GetRows(), and cloudViewer::core::Int64.
Referenced by cloudViewer::t::geometry::pybind_image().
|
inline |
Compute min 2D coordinates for the data (always {0, 0}).
Definition at line 315 of file Image.h.
References cloudViewer::core::Int64, and cloudViewer::core::Tensor::Zeros().
Referenced by cloudViewer::t::geometry::pybind_image().
|
inline |
Get the number of rows of the image.
Definition at line 84 of file Image.h.
References data_, and cloudViewer::core::Tensor::GetShape().
Referenced by ClipTransform(), ColorizeDepth(), CreateNormalMap(), cloudViewer::t::geometry::CreatePointCloudWithNormals(), CreateVertexMap(), cloudViewer::t::pipelines::slac::ControlGrid::Deform(), GetMaxBound(), cloudViewer::t::geometry::RGBDImage::GetMaxBound(), cloudViewer::t::geometry::VoxelBlockGrid::GetUniqueBlockCoordinates(), IsEmpty(), cloudViewer::t::geometry::pybind_image(), PyrDownDepth(), Resize(), cloudViewer::t::geometry::RGBDImage::RGBDImage(), RGBToGray(), cloudViewer::t::io::DepthNoiseSimulator::Simulate(), To(), ToLegacy(), ToString(), and cloudViewer::t::geometry::RGBDImage::ToString().
|
inlineoverridevirtual |
Returns true if rows * cols * channels == 0.
Implements cloudViewer::t::geometry::Geometry.
Definition at line 71 of file Image.h.
References GetChannels(), GetCols(), and GetRows().
Referenced by cloudViewer::t::geometry::RGBDImage::IsEmpty(), and cloudViewer::t::geometry::pybind_image().
|
inline |
Function to linearly transform pixel intensities in place.
.
| scale | First multiply image pixel values with this factor. This should be positive for unsigned dtypes. |
| offset | Then add this factor to all image pixel values. |
Definition at line 167 of file Image.h.
References GetDtype(), offset, and To().
Referenced by cloudViewer::t::geometry::pybind_image().
| Image cloudViewer::t::geometry::Image::PyrDown | ( | ) | const |
Return a new downsampled image with pyramid downsampling.
The returned image is formed by a chained Gaussian filter (kernel_size = 5, sigma = 1.0) and a resize (ratio = 0.5) operation.
Definition at line 395 of file Image.cpp.
References FilterGaussian(), Nearest, and Resize().
Referenced by cloudViewer::t::geometry::pybind_image(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleHybrid(), and cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleIntensity().
| Image cloudViewer::t::geometry::Image::PyrDownDepth | ( | float | diff_threshold, |
| float | invalid_fill = 0.f |
||
| ) | const |
Edge and invalid value preserving downsampling by 2 specifically for depth images.
Only 1 channel Float32 images are supported. The returned image is formed by a chained Gaussian filter (kernel_size = 5, sigma = 1.0) and a resize (ratio = 0.5) operation.
| diff_threshold | The Gaussian filter averaging ignores neighboring values if the depth difference is larger than this value. |
| invalid_fill | The Gaussian filter ignores these values (may be specified as NAN, INFINITY or 0.0 (default)). |
Definition at line 400 of file Image.cpp.
References AssertTensorDtype, AsTensor(), cloudViewer::core::Tensor::Empty(), cloudViewer::core::Float32, GetChannels(), GetCols(), GetDevice(), GetDtype(), GetRows(), LogError, and cloudViewer::t::geometry::kernel::image::PyrDownDepth().
Referenced by cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleHybrid(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleIntensity(), and cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScalePointToPlane().
| Image & cloudViewer::t::geometry::Image::Reset | ( | int64_t | rows = 0, |
| int64_t | cols = 0, |
||
| int64_t | channels = 1, |
||
| core::Dtype | dtype = core::Float32, |
||
| const core::Device & | device = core::Device("CPU:0") |
||
| ) |
| Image cloudViewer::t::geometry::Image::Resize | ( | float | sampling_rate = 0.5f, |
| InterpType | interp_type = InterpType::Nearest |
||
| ) | const |
Return a new image after resizing with specified interpolation type.
Downsample if sampling rate is < 1. Upsample if sampling rate > 1. Aspect ratio is always preserved.
Definition at line 156 of file Image.cpp.
References cloudViewer::core::Bool, count, CUDA_CALL, data_, cloudViewer::core::Tensor::Empty(), cloudViewer::core::Float32, GetChannels(), GetCols(), GetDevice(), GetDtype(), GetRows(), HAVE_IPP, Image(), IPP_CALL, cloudViewer::core::IsDevice::IsCPU(), cloudViewer::core::IsDevice::IsCUDA(), LogError, cloudViewer::core::make_pair(), cloudViewer::core::Tensor::ReinterpretCast(), cloudViewer::t::geometry::npp::Resize(), cloudViewer::t::geometry::ipp::Resize(), ToString(), cloudViewer::core::UInt16, and cloudViewer::core::UInt8.
Referenced by cloudViewer::t::geometry::pybind_image(), and PyrDown().
| Image cloudViewer::t::geometry::Image::RGBToGray | ( | ) | const |
Converts a 3-channel RGB image to a new 1-channel Grayscale image.
Uses formula
.
Definition at line 120 of file Image.cpp.
References count, CUDA_CALL, data_, cloudViewer::core::Tensor::Empty(), cloudViewer::core::Float32, GetChannels(), GetCols(), GetDevice(), GetDtype(), GetRows(), HAVE_IPP, IPP_CALL, cloudViewer::core::IsDevice::IsCPU(), cloudViewer::core::IsDevice::IsCUDA(), LogError, cloudViewer::core::make_pair(), cloudViewer::t::geometry::ipp::RGBToGray(), cloudViewer::t::geometry::npp::RGBToGray(), ToString(), cloudViewer::core::UInt16, and cloudViewer::core::UInt8.
Referenced by cloudViewer::t::geometry::pybind_image(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleHybrid(), and cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleIntensity().
|
inline |
Transfer the image to a specified device.
| device | The targeted device to convert to. |
| copy | If true, a new image is always created; if false, the copy is avoided when the original image is already on the targeted device. |
Definition at line 132 of file Image.h.
References copy, data_, Image(), and cloudViewer::core::Tensor::To().
Referenced by Clone(), cloudViewer::t::pipelines::odometry::ComputeOdometryResultPointToPlane(), CPU(), cloudViewer::t::geometry::PointCloud::CreateFromRGBDImage(), LinearTransform(), cloudViewer::t::geometry::TriangleMesh::ProjectImagesToAlbedo(), cloudViewer::t::geometry::pybind_image(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScale(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleHybrid(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScaleIntensity(), cloudViewer::t::geometry::TriangleMesh::SamplePointsUniformly(), and cloudViewer::t::geometry::RGBDImage::To().
| Image cloudViewer::t::geometry::Image::To | ( | core::Dtype | dtype, |
| bool | copy = false, |
||
| utility::optional< double > | scale = utility::nullopt, |
||
| double | offset = 0.0 |
||
| ) | const |
Returns an Image with the specified dtype.
| dtype | The targeted dtype to convert to. |
| copy | If true, a new tensor is always created; if false, the copy is avoided when the original tensor already has the targeted dtype. |
| scale | Optional scale value. This is 1./255 for UInt8 -> Float{32,64}, 1./65535 for UInt16 -> Float{32,64} and 1 otherwise |
| offset | Optional shift value. Default 0. |
Definition at line 75 of file Image.cpp.
References cloudViewer::core::Bool, cloudViewer::core::Tensor::Clone(), copy, count, data_, cloudViewer::core::Tensor::Empty(), cloudViewer::core::Float32, cloudViewer::core::Float64, GetChannels(), GetCols(), GetDevice(), GetDtype(), GetRows(), cloudViewer::utility::optional< T >::has_value(), HAVE_IPP, Image(), cloudViewer::core::Int32, IPP_CALL, cloudViewer::core::IsDevice::IsCPU(), offset, cloudViewer::t::geometry::kernel::image::To(), cloudViewer::t::geometry::ipp::To(), cloudViewer::core::UInt16, cloudViewer::core::UInt8, and cloudViewer::utility::optional< T >::value_or().
| cloudViewer::geometry::Image cloudViewer::t::geometry::Image::ToLegacy | ( | ) | const |
Convert to legacy Image type.
Definition at line 534 of file Image.cpp.
References cloudViewer::geometry::Image::BytesPerLine(), data_, cloudViewer::geometry::Image::data_, cloudViewer::core::Float32, GetChannels(), GetCols(), cloudViewer::core::Tensor::GetDataPtr(), cloudViewer::core::Tensor::GetDevice(), GetDtype(), GetRows(), cloudViewer::geometry::Image::height_, cloudViewer::core::Tensor::IsContiguous(), LogError, cloudViewer::core::MemoryManager::MemcpyToHost(), cloudViewer::geometry::Image::Prepare(), cloudViewer::core::UInt16, and cloudViewer::core::UInt8.
Referenced by cloudViewer::t::geometry::pybind_image(), and cloudViewer::t::geometry::RGBDImage::ToLegacy().
| std::string cloudViewer::t::geometry::Image::ToString | ( | ) | const |
Text description.
Definition at line 555 of file Image.cpp.
References format, GetChannels(), GetCols(), GetDevice(), GetDtype(), and GetRows().
Referenced by Dilate(), Filter(), FilterBilateral(), FilterGaussian(), FilterSobel(), cloudViewer::t::geometry::pybind_image(), Resize(), and RGBToGray().
|
protected |
Internal data of the Image, represented as a contiguous 3D tensor of shape {rows, cols, channels}. Image properties can be obtained from the tensor.
Definition at line 346 of file Image.h.
Referenced by AsTensor(), At(), Clear(), ClipTransform(), ColorizeDepth(), CreateNormalMap(), CreateVertexMap(), Dilate(), Filter(), FilterBilateral(), FilterGaussian(), FilterSobel(), GetChannels(), GetCols(), GetDataPtr(), GetDevice(), GetDtype(), GetRows(), Image(), Reset(), Resize(), RGBToGray(), To(), and ToLegacy().
|
staticconstexpr |
Do we use IPP for accelerating image processing operations?
Definition at line 339 of file Image.h.
Referenced by cloudViewer::t::pipelines::odometry::ComputeOdometryResultPointToPlane(), Dilate(), Filter(), FilterBilateral(), FilterGaussian(), FilterSobel(), cloudViewer::t::geometry::TriangleMesh::ProjectImagesToAlbedo(), Resize(), cloudViewer::t::pipelines::odometry::RGBDOdometryMultiScale(), RGBToGray(), and To().