NVIDIA NvNeural SDK  2022.2
GPU inference framework for NVIDIA Nsight Deep Learning Designer
nvneural::Image Class Reference

Standard implementation for IFileImage. More...

#include <CpuImage.h>

Inheritance diagram for nvneural::Image:
nvneural::refobj::RefObjectBase< nvneural::refobj::Implements< nvneural::IFileImage >, nvneural::refobj::Implements< nvneural::IImage > >

Public Member Functions

std::size_t channels () const noexcept
 Returns the number of color channels in the image. More...
 
const std::uint8_t * data () const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::uint8_t * data () noexcept
 Returns a pointer to the raw pixel data in HWC layout. More...
 
std::size_t elements () const noexcept
 Returns the number of data elements in the image. More...
 
NeuralResult fromFill (std::size_t height, std::size_t width, std::size_t channels, std::uint8_t fillValue) noexcept
 Loads an image by tiling a fill value. More...
 
NeuralResult fromRandomValues (std::size_t height, std::size_t width, std::size_t channels) noexcept
 Loads an image by generating normally distributed noise in the range [0, 255]. More...
 
std::size_t height () const noexcept
 Returns the height of the image in pixels. More...
 
NeuralResult loadFromDescriptors (const std::vector< ImageDescriptor > &descriptors) noexcept
 Loads an image from a chained set of descriptors. More...
 
NeuralResult loadFromFile (const std::string &filename) noexcept
 Loads an image from a single bitmap file. More...
 
NeuralResult resize (std::size_t height, std::size_t width, std::size_t channels) noexcept
 Clears the image and reserves storage. More...
 
NeuralResult saveToFile (const std::string &filename) noexcept
 Saves the resulting image as a file. More...
 
std::size_t width () const noexcept
 Returns the width of the image in pixels. More...
 
- Public Member Functions inherited from nvneural::refobj::RefObjectBase< nvneural::refobj::Implements< nvneural::IFileImage >, nvneural::refobj::Implements< nvneural::IImage > >
IRefObject::RefCount addRef () const noexcept
 Increment the object's reference count. More...
 
const void * queryInterface (IRefObject::TypeId interfaceId) const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void * queryInterface (IRefObject::TypeId interfaceId) noexcept
 Retrieves a new object interface pointer. More...
 
 RefObjectBase ()
 Default constructor. Logs object creation.
 
IRefObject::RefCount release () const noexcept
 Decrements the object's reference count and destroys the object if the reference count reaches zero. More...
 

Detailed Description

Standard implementation for IFileImage.

Member Function Documentation

◆ channels()

size_t Image::channels ( ) const
noexcept

Returns the number of color channels in the image.

◆ data()

uint8_t * Image::data ( )
noexcept

Returns a pointer to the raw pixel data in HWC layout.

Returns nullptr if the object is not in a valid state.

◆ elements()

size_t Image::elements ( ) const
noexcept

Returns the number of data elements in the image.

This can be calculated as height * width * channels.

◆ fromFill()

NeuralResult Image::fromFill ( std::size_t  height,
std::size_t  width,
std::size_t  channels,
std::uint8_t  fillValue 
)
noexcept

Loads an image by tiling a fill value.

Replaces existing data.

Parameters
heightHeight of the resulting image
widthWidth of the resulting image
channelsChannel count of the resulting image
fillValueByte to fill the image with; per-channel fills are not supported

◆ fromRandomValues()

NeuralResult Image::fromRandomValues ( std::size_t  height,
std::size_t  width,
std::size_t  channels 
)
noexcept

Loads an image by generating normally distributed noise in the range [0, 255].

Replaces existing data.

Parameters
heightHeight of the resulting image
widthWidth of the resulting image
channelsChannel count of the resulting image

◆ height()

size_t Image::height ( ) const
noexcept

Returns the height of the image in pixels.

◆ loadFromDescriptors()

NeuralResult Image::loadFromDescriptors ( const std::vector< ImageDescriptor > &  descriptors)
noexcept

Loads an image from a chained set of descriptors.

Replaces existing data.

At this time, only a single descriptor is supported. Future versions of the framework may support concatenation of image data using sets of descriptors. Loading from npy files is the recommended alternative.

Parameters
descriptorsList of descriptors

◆ loadFromFile()

NeuralResult Image::loadFromFile ( const std::string &  filename)
noexcept

Loads an image from a single bitmap file.

Replaces existing data.

Parameters
filenameFile path to load

◆ resize()

NeuralResult Image::resize ( std::size_t  height,
std::size_t  width,
std::size_t  channels 
)
noexcept

Clears the image and reserves storage.

This ensures operations on data() will have an appropriately sized canvas.

◆ saveToFile()

NeuralResult Image::saveToFile ( const std::string &  filename)
noexcept

Saves the resulting image as a file.

Parameters
filenameFile path to save

◆ width()

size_t Image::width ( ) const
noexcept

Returns the width of the image in pixels.


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