Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::PixelType Class Reference

Describes the data type of image pixels. More...

#include <mitkPixelType.h>

Public Types

typedef itk::IOPixelEnum ItkIOPixelType
 ITK I/O pixel type enumeration. More...
 
typedef itk::IOComponentEnum ItkIOComponentType
 ITK I/O component type enumeration. More...
 

Public Member Functions

 PixelType (const mitk::PixelType &aPixelType)
 Copy constructor. More...
 
PixelType & operator= (const PixelType &other)
 Copy assignment operator. More...
 
ItkIOPixelType GetPixelType () const
 Get the ITK I/O pixel type enumeration value. More...
 
ItkIOComponentType GetComponentType () const
 Get the scalar component type. More...
 
std::string GetPixelTypeAsString () const
 Get the ITK pixel type as a human-readable string. More...
 
std::string GetComponentTypeAsString () const
 Get the scalar component type as a human-readable string. More...
 
std::string GetTypeAsString () const
 Get a combined string of pixel type and component type. More...
 
size_t GetSize () const
 Get the total size of one pixel in bytes. More...
 
size_t GetBpe () const
 Get the total number of bits per pixel element. More...
 
size_t GetNumberOfComponents () const
 Get the number of components per pixel. More...
 
size_t GetBitsPerComponent () const
 Get the number of bits per single scalar component. More...
 
bool operator== (const PixelType &rhs) const
 Compare two PixelType objects for equality. More...
 
bool operator!= (const PixelType &rhs) const
 Compare two PixelType objects for inequality. More...
 
 ~PixelType ()
 Destructor. More...
 

Detailed Description

Describes the data type of image pixels.

Encapsulates all information about an image's pixel type, including the scalar component type, the composite pixel type (e.g. scalar, RGB, vector), the number of components per pixel, and the byte sizes.

To obtain additional type information not provided by this class, itk::ImageIOBase can be used by passing the return value of PixelType::GetComponentType() to itk::ImageIOBase::SetPixelTypeInfo and using the itk::ImageIOBase methods GetComponentType, GetComponentTypeAsString, GetPixelType, GetPixelTypeAsString.

Instances are created via the MakePixelType() family of factory functions rather than constructing directly.

See also
MakePixelType, MakeScalarPixelType, ChannelDescriptor, ImageDescriptor

Definition at line 74 of file mitkPixelType.h.

Member Typedef Documentation

◆ ItkIOComponentType

typedef itk::IOComponentEnum mitk::PixelType::ItkIOComponentType

ITK I/O component type enumeration.

Definition at line 78 of file mitkPixelType.h.

◆ ItkIOPixelType

typedef itk::IOPixelEnum mitk::PixelType::ItkIOPixelType

ITK I/O pixel type enumeration.

Definition at line 77 of file mitkPixelType.h.

Constructor & Destructor Documentation

◆ PixelType()

mitk::PixelType::PixelType ( const mitk::PixelType &  aPixelType)

Copy constructor.

Parameters
[in]aPixelTypeThe PixelType to copy from.

◆ ~PixelType()

mitk::PixelType::~PixelType ( )

Destructor.

Member Function Documentation

◆ GetBitsPerComponent()

size_t mitk::PixelType::GetBitsPerComponent ( ) const

Get the number of bits per single scalar component.

Equals bytes-per-component * 8.

Returns
Number of bits per component.
See also
GetBpe

◆ GetBpe()

size_t mitk::PixelType::GetBpe ( ) const

Get the total number of bits per pixel element.

Equals GetSize() * 8. For example, a 3-component double vector returns 8 * sizeof(double) * 3 = 192.

Returns
Number of bits per pixel element.
See also
GetBitsPerComponent, GetSize

◆ GetComponentType()

ItkIOComponentType mitk::PixelType::GetComponentType ( ) const

Get the scalar component type.

Each pixel element may contain multiple components of this scalar type. For example, an RGB pixel of floats has component type FLOAT.

Returns
The component type enum.

Referenced by mitk::ImageGenerator::GenerateRandomImage().

◆ GetComponentTypeAsString()

std::string mitk::PixelType::GetComponentTypeAsString ( ) const

Get the scalar component type as a human-readable string.

Returns
A string such as "float", "unsigned_char", etc.

◆ GetNumberOfComponents()

size_t mitk::PixelType::GetNumberOfComponents ( ) const

Get the number of components per pixel.

Each pixel can consist of multiple components (e.g. RGB has 3, RGBA has 4, a scalar has 1).

Returns
The number of components.

Referenced by mitk::ImagePixelAccessor< TPixel, VDimension >::CheckData(), and mitk::ImagePixelReadAccessor< TPixel, VDimension >::GetConsecutivePixelsAsVector().

◆ GetPixelType()

ItkIOPixelType mitk::PixelType::GetPixelType ( ) const

Get the ITK I/O pixel type enumeration value.

Identifies the composite pixel type (e.g. SCALAR, RGB, VECTOR).

Returns
The pixel type enum.

◆ GetPixelTypeAsString()

std::string mitk::PixelType::GetPixelTypeAsString ( ) const

Get the ITK pixel type as a human-readable string.

Returns
A string such as "scalar", "rgb", "vector", etc.

◆ GetSize()

size_t mitk::PixelType::GetSize ( ) const

Get the total size of one pixel in bytes.

Equals GetNumberOfComponents() * bytes-per-component. For example, an RGBA float pixel returns 4 * sizeof(float) = 16.

Returns
Size in bytes.

◆ GetTypeAsString()

std::string mitk::PixelType::GetTypeAsString ( ) const

Get a combined string of pixel type and component type.

The format is "PixelTypeName (ComponentTypeName)".

Returns
A descriptive string such as "rgb (float)".

◆ operator!=()

bool mitk::PixelType::operator!= ( const PixelType &  rhs) const

Compare two PixelType objects for inequality.

Parameters
[in]rhsThe PixelType to compare against.
Returns
True if not equal.

◆ operator=()

PixelType& mitk::PixelType::operator= ( const PixelType &  other)

Copy assignment operator.

Parameters
[in]otherThe PixelType to assign from.
Returns
Reference to this object.

◆ operator==()

bool mitk::PixelType::operator== ( const PixelType &  rhs) const

Compare two PixelType objects for equality.

Two PixelTypes are equal if they share the same pixel type, component type, number of components, and bytes per component.

Parameters
[in]rhsThe PixelType to compare against.
Returns
True if equal.

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