Open3D (C++ API)  0.11.0
Public Member Functions | Protected Attributes
open3d::t::geometry::Image Class Reference

The Image class stores image with customizable rols, cols, channels, dtype and device. More...

#include <Image.h>

Inheritance diagram for open3d::t::geometry::Image:
open3d::t::geometry::Geometry

Public Member Functions

 Image (int64_t rows=0, int64_t cols=0, int64_t channels=1, core::Dtype dtype=core::Dtype::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
 
ImageClear () override
 
bool IsEmpty () const override
 Returns true if rows * cols * channels == 0. 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
 Get device of the image. More...
 
core::Tensor At (int64_t r, int64_t c) const
 
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
 Retuns the underlying Tensor of the Image. More...
 
- Public Member Functions inherited from open3d::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...
 

Protected Attributes

core::Tensor data_
 

Additional Inherited Members

- Public Types inherited from open3d::t::geometry::Geometry
enum  GeometryType {
  GeometryType::Unspecified = 0, GeometryType::PointCloud = 1, GeometryType::VoxelGrid = 2, GeometryType::Octree = 3,
  GeometryType::LineSet = 4, GeometryType::MeshBase = 5, GeometryType::TriangleMesh = 6, GeometryType::HalfEdgeTriangleMesh = 7,
  GeometryType::Image = 8, GeometryType::RGBDImage = 9, GeometryType::TetraMesh = 10, GeometryType::OrientedBoundingBox = 11,
  GeometryType::AxisAlignedBoundingBox = 12
}
 Specifies possible geometry types. More...
 
- Protected Member Functions inherited from open3d::t::geometry::Geometry
 Geometry (GeometryType type, int dimension)
 Parameterized Constructor. More...
 

Detailed Description

The Image class stores image with customizable rols, cols, channels, dtype and device.

Constructor & Destructor Documentation

◆ Image() [1/2]

open3d::t::geometry::Image::Image ( int64_t  rows = 0,
int64_t  cols = 0,
int64_t  channels = 1,
core::Dtype  dtype = core::Dtype::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.

Parameters
rowsNumber of rows of the image, i.e. image height. rows must be non-negative.
colsNumber of columns of the image, i.e. image width. cols must be non-negative.
channelsNumber of channels of the image. E.g. for RGB image, channels == 3; for grayscale image, channels == 1. channels must be greater than 0.
dtypeData type of the image.
deviceDevice where the image is stored.

◆ Image() [2/2]

open3d::t::geometry::Image::Image ( const core::Tensor tensor)

Construct from a tensor. The tensor won't be copied and memory will be shared.

Parameters
tensorTensor of the image. The tensor must be contiguous. The tensor must be 2D (rows, cols) or 3D (rows, cols, channels).

◆ ~Image()

virtual open3d::t::geometry::Image::~Image ( )
inlineoverridevirtual

Member Function Documentation

◆ AsTensor()

core::Tensor open3d::t::geometry::Image::AsTensor ( ) const
inline

Retuns the underlying Tensor of the Image.

◆ At() [1/2]

core::Tensor open3d::t::geometry::Image::At ( int64_t  r,
int64_t  c 
) const
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.

◆ At() [2/2]

core::Tensor open3d::t::geometry::Image::At ( int64_t  r,
int64_t  c,
int64_t  ch 
) const
inline

Get pixel(s) in the image. Returns a tensor with shape {}.

◆ Clear()

Image& open3d::t::geometry::Image::Clear ( )
inlineoverridevirtual

Clear image contents by resetting the rows and cols to 0, while keeping channels, dtype and device unchanged.

Implements open3d::t::geometry::Geometry.

◆ GetChannels()

int64_t open3d::t::geometry::Image::GetChannels ( ) const
inline

Get the number of channels of the image.

◆ GetCols()

int64_t open3d::t::geometry::Image::GetCols ( ) const
inline

Get the number of columns of the image.

◆ GetDataPtr() [1/2]

void* open3d::t::geometry::Image::GetDataPtr ( )
inline

Get raw buffer of the Image data.

◆ GetDataPtr() [2/2]

const void* open3d::t::geometry::Image::GetDataPtr ( ) const
inline

Get raw buffer of the Image data.

◆ GetDevice()

core::Device open3d::t::geometry::Image::GetDevice ( ) const
inline

Get device of the image.

◆ GetDtype()

core::Dtype open3d::t::geometry::Image::GetDtype ( ) const
inline

Get dtype of the image.

◆ GetRows()

int64_t open3d::t::geometry::Image::GetRows ( ) const
inline

Get the number of rows of the image.

◆ IsEmpty()

bool open3d::t::geometry::Image::IsEmpty ( ) const
inlineoverridevirtual

Returns true if rows * cols * channels == 0.

Implements open3d::t::geometry::Geometry.

Field Documentation

◆ data_

core::Tensor open3d::t::geometry::Image::data_
protected

Internal data of the Image, represented as a 3D tensor of shape {rols, cols, channels}. Image properties can be obtained from the tensor.


The documentation for this class was generated from the following files: