MorphologicalAttributeFilters
Public API documentation
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | 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 cols)
 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 getNumCols () const
 Returns the number of image columns.
 
int getSize () const
 Returns the total number of pixels.
 
PixelTypeoperator[] (int index)
 Returns mutable linear access to pixel index.
 
const PixelTypeoperator[] (int index) const
 Returns immutable linear access to pixel index.
 

Static Public Member Functions

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

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 37 of file Image.hpp.

Member Typedef Documentation

◆ Type

Pixel scalar type stored by this image.

Definition at line 58 of file Image.hpp.

Constructor & Destructor Documentation

◆ Image()

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

Allocates an owned row-major image buffer.

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

Definition at line 68 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 * cols).

Definition at line 178 of file Image.hpp.

◆ create() [1/2]

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

Creates an owned image with uninitialised pixel values.

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

Definition at line 79 of file Image.hpp.

◆ create() [2/2]

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

Creates an owned image and fills every pixel with initValue.

Parameters
rowsNumber of image rows.
colsNumber 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 * cols exceeds the supported size.

Definition at line 93 of file Image.hpp.

◆ fill()

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

Fills every pixel with value.

Complexity: O(rows * cols).

Definition at line 148 of file Image.hpp.

◆ fromExternal()

template<typename PixelType >
static Ptr mmcfilters::Image< PixelType >::fromExternal ( PixelType rawPtr,
int  rows,
int  cols 
)
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 * cols row-major pixels.
rowsNumber of image rows.
colsNumber of image columns.
Returns
Shared non-owning image wrapper.
Exceptions
std::invalid_argumentIf rawPtr is null or dimensions are invalid.
std::overflow_errorIf rows * cols exceeds the supported size.

Definition at line 112 of file Image.hpp.

◆ fromRaw()

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

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

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

Definition at line 133 of file Image.hpp.

◆ getNumCols()

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

Returns the number of image columns.

Definition at line 209 of file Image.hpp.

◆ getNumRows()

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

Returns the number of image rows.

Definition at line 204 of file Image.hpp.

◆ getSize()

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

Returns the total number of pixels.

Definition at line 214 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 * cols).

Definition at line 160 of file Image.hpp.

◆ operator[]() [1/2]

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

Returns mutable linear access to pixel index.

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

Definition at line 222 of file Image.hpp.

◆ operator[]() [2/2]

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

Returns immutable linear access to pixel index.

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

Definition at line 230 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.

Definition at line 199 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.

Definition at line 191 of file Image.hpp.


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