mmcfilters
Public API documentation
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
mmcfilters::Image< PixelType > Class Template Reference

Generic row-major 2D image with contiguous storage and shared ownership. More...

#include <Image.hpp>

Public Types

using Type = PixelType
 Pixel scalar type stored by this image.
 

Public Member Functions

 Image (int rows, int columns)
 Allocates an owned row-major image buffer.
 
void fill (PixelType value)
 Fills every pixel with value.
 
bool isEqual (const Ptr &other) const
 Returns true when shape and pixel values match other.
 
Ptr clone () const
 Returns a deep copy with its own owned buffer.
 
std::shared_ptr< PixelType[]> rawDataPtr ()
 Returns the shared pointer that owns or wraps the raw buffer.
 
PixelTyperawData ()
 Returns a mutable pointer to the contiguous row-major buffer.
 
int getNumRows () const
 Returns the number of image rows.
 
int getNumColumns () const
 Returns the number of image columns.
 
int getSize () const
 Returns the total number of pixels.
 
PixelTypeoperator[] (PixelId index)
 Returns mutable linear access to pixel index.
 
const PixelTypeoperator[] (PixelId index) const
 Returns immutable linear access to pixel index.
 

Static Public Member Functions

static Ptr create (int rows, int columns)
 Creates an owned image with uninitialised pixel values.
 
static Ptr create (int rows, int columns, PixelType initValue)
 Creates an owned image and fills every pixel with initValue.
 
static Ptr fromExternal (PixelType *rawPtr, int rows, int columns)
 Wraps external row-major memory without taking ownership.
 
static Ptr fromRaw (PixelType *rawPtr, int rows, int columns)
 Wraps row-major memory and takes ownership through delete[].
 

Friends

class detail::CommittedImageAccess
 

Detailed Description

template<typename PixelType>
class mmcfilters::Image< PixelType >

Generic row-major 2D image with contiguous storage and shared ownership.

Image<PixelType> stores a rectangular image in a single contiguous row-major buffer. The class exposes simple factory helpers for owned and non-owned memory, deep copy support, linear access, and a few convenience operations used throughout the library.

Ownership semantics:

Template Parameters
PixelTypePixel scalar type, such as uint8_t, int32_t, or float.

Definition at line 43 of file Image.hpp.

Member Typedef Documentation

◆ Type

Pixel scalar type stored by this image.

Definition at line 84 of file Image.hpp.

Constructor & Destructor Documentation

◆ Image()

template<typename PixelType >
mmcfilters::Image< PixelType >::Image ( int  rows,
int  columns 
)
inline

Allocates an owned row-major image buffer.

Parameters
rowsNumber of image rows.
columnsNumber of image columns.
Exceptions
std::invalid_argumentIf either dimension is not positive.
std::overflow_errorIf rows * columns exceeds the supported size.

Definition at line 94 of file Image.hpp.

Member Function Documentation

◆ clone()

template<typename PixelType >
Ptr mmcfilters::Image< PixelType >::clone ( ) const
inline

Returns a deep copy with its own owned buffer.

Returns
New image with the same dimensions and pixel values.

Complexity: O(rows * columns).

Definition at line 197 of file Image.hpp.

◆ create() [1/2]

template<typename PixelType >
static Ptr mmcfilters::Image< PixelType >::create ( int  rows,
int  columns 
)
inlinestatic

Creates an owned image with uninitialised pixel values.

Parameters
rowsNumber of image rows.
columnsNumber of image columns.
Returns
Shared owning image wrapper.
Exceptions
std::invalid_argumentIf either dimension is not positive.
std::overflow_errorIf rows * columns exceeds the supported size.

Definition at line 105 of file Image.hpp.

◆ create() [2/2]

template<typename PixelType >
static Ptr mmcfilters::Image< PixelType >::create ( int  rows,
int  columns,
PixelType  initValue 
)
inlinestatic

Creates an owned image and fills every pixel with initValue.

Parameters
rowsNumber of image rows.
columnsNumber of image columns.
initValueValue assigned to every pixel.
Returns
Shared owning image wrapper.
Exceptions
std::invalid_argumentIf either dimension is not positive.
std::overflow_errorIf rows * columns exceeds the supported size.

Definition at line 117 of file Image.hpp.

◆ fill()

template<typename PixelType >
void mmcfilters::Image< PixelType >::fill ( PixelType  value)
inline

Fills every pixel with value.

Complexity: O(rows * columns).

Parameters
valueValue.

Definition at line 169 of file Image.hpp.

◆ fromExternal()

template<typename PixelType >
static Ptr mmcfilters::Image< PixelType >::fromExternal ( PixelType rawPtr,
int  rows,
int  columns 
)
inlinestatic

Wraps external row-major memory without taking ownership.

The caller remains responsible for keeping rawPtr alive while the image wrapper is used.

Parameters
rawPtrPointer to rows * columns row-major pixels.
rowsNumber of image rows.
columnsNumber of image columns.
Returns
Shared non-owning image wrapper.
Exceptions
std::invalid_argumentIf rawPtr is null or dimensions are invalid.
std::overflow_errorIf rows * columns exceeds the supported size.

Definition at line 136 of file Image.hpp.

◆ fromRaw()

template<typename PixelType >
static Ptr mmcfilters::Image< PixelType >::fromRaw ( PixelType rawPtr,
int  rows,
int  columns 
)
inlinestatic

Wraps row-major memory and takes ownership through delete[].

Parameters
rawPtrPointer allocated with new PixelType[].
rowsNumber of image rows.
columnsNumber of image columns.
Returns
Shared owning image wrapper.
Exceptions
std::invalid_argumentIf rawPtr is null or dimensions are invalid.
std::overflow_errorIf rows * columns exceeds the supported size.

Definition at line 155 of file Image.hpp.

◆ getNumColumns()

template<typename PixelType >
int mmcfilters::Image< PixelType >::getNumColumns ( ) const
inline

Returns the number of image columns.

Returns
The number of image columns.

Definition at line 236 of file Image.hpp.

◆ getNumRows()

template<typename PixelType >
int mmcfilters::Image< PixelType >::getNumRows ( ) const
inline

Returns the number of image rows.

Returns
The number of image rows.

Definition at line 229 of file Image.hpp.

◆ getSize()

template<typename PixelType >
int mmcfilters::Image< PixelType >::getSize ( ) const
inline

Returns the total number of pixels.

Returns
The total number of pixels.

Definition at line 243 of file Image.hpp.

◆ isEqual()

template<typename PixelType >
bool mmcfilters::Image< PixelType >::isEqual ( const Ptr &  other) const
inline

Returns true when shape and pixel values match other.

Parameters
otherNon-null image pointer to compare against.
Returns
True only when dimensions and every row-major pixel match.

Complexity: O(rows * columns).

Definition at line 179 of file Image.hpp.

◆ operator[]() [1/2]

template<typename PixelType >
PixelType & mmcfilters::Image< PixelType >::operator[] ( PixelId  index)
inline

Returns mutable linear access to pixel index.

index is interpreted in row-major order as row * getNumColumns() + column. The operator does not perform bounds checking.

Parameters
indexZero-based index.
Returns
Mutable linear access to pixel index.

Definition at line 254 of file Image.hpp.

◆ operator[]() [2/2]

template<typename PixelType >
const PixelType & mmcfilters::Image< PixelType >::operator[] ( PixelId  index) const
inline

Returns immutable linear access to pixel index.

index is interpreted in row-major order as row * getNumColumns() + column. The operator does not perform bounds checking.

Parameters
indexZero-based index.
Returns
Immutable linear access to pixel index.

Definition at line 265 of file Image.hpp.

◆ rawData()

template<typename PixelType >
PixelType * mmcfilters::Image< PixelType >::rawData ( )
inline

Returns a mutable pointer to the contiguous row-major buffer.

The pointer remains valid while the image object and its shared buffer are alive and no external owner invalidates externally wrapped memory.

Returns
A mutable pointer to the contiguous row-major buffer.

Definition at line 222 of file Image.hpp.

◆ rawDataPtr()

template<typename PixelType >
std::shared_ptr< PixelType[]> mmcfilters::Image< PixelType >::rawDataPtr ( )
inline

Returns the shared pointer that owns or wraps the raw buffer.

The returned pointer shares the same ownership/lifetime policy as this image: either owning storage, externally wrapped storage, or adopted raw storage.

Returns
The shared pointer that owns or wraps the raw buffer.

Definition at line 212 of file Image.hpp.

Friends And Related Symbol Documentation

◆ detail::CommittedImageAccess

template<typename PixelType >
friend class detail::CommittedImageAccess
friend

Definition at line 45 of file Image.hpp.


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