Class for defining the data type of pixels. More...
#include <mitkPixelType.h>
Public Types | |
| typedef itk::ImageIOBase::IOPixelType | ItkIOPixelType |
Public Member Functions | |
| virtual const char * | GetClassName () const |
| PixelType (const std::type_info &aTypeId, int numberOfComponents=1, ItkIOPixelType anItkIoPixelType=itk::ImageIOBase::UNKNOWNPIXELTYPE) | |
| PixelType (mitkIpPicType_t type, int bpe, int numberOfComponents=1) | |
| PixelType (const mitkIpPicDescriptor *pic) | |
| PixelType (const mitk::PixelType &aPixelType) | |
| const std::type_info * | GetTypeId () const |
| Get the type_info of the scalar (!) type. Each element may contain m_NumberOfComponents (more than one) of these scalars. | |
| const std::type_info * | GetItkTypeId () const |
| Get the type_info of the ITK-type representing an element. Can be NULL in case the ITK-type is unknown. | |
| mitkIpPicType_t | GetType () const |
| Get the mitkIpPicType_t of the scalar (!) component type. Each element may contain m_NumberOfComponents (more than one) of these scalars. | |
| int | GetBpe () const |
| Get the number of bits per element (of an element) | |
| int | GetNumberOfComponents () const |
| Get the number of components of which each element consists. | |
| int | GetBitsPerComponent () const |
| Get the number of bits per components. | |
| std::string | GetItkTypeAsString () const |
| Get the typename of the ITK-type representing an element as a human-readable string. | |
| PixelType & | operator= (const PixelType &aPixelType) |
| bool | operator== (const PixelType &rhs) const |
| bool | operator!= (const PixelType &rhs) const |
| bool | operator== (const std::type_info &typeId) const |
| bool | operator!= (const std::type_info &typeId) const |
| PixelType () | |
| void | Initialize (const std::type_info &aTypeId, int numberOfCompontents=1, ItkIOPixelType anItkIoPixelType=itk::ImageIOBase::UNKNOWNPIXELTYPE) |
| void | Initialize (mitkIpPicType_t type, int bpe, int numberOfComponents=1) |
| virtual | ~PixelType () |
Class for defining the data type of pixels.
To obtain additional type information not provided by this class itk::ImageIOBase can be used by passing the return value of PixelType::GetItkTypeId() to itk::ImageIOBase::SetPixelTypeInfo and using the itk::ImageIOBase methods GetComponentType, GetComponentTypeAsString, GetPixelType, GetPixelTypeAsString.
Definition at line 37 of file mitkPixelType.h.
| typedef itk::ImageIOBase::IOPixelType mitk::PixelType::ItkIOPixelType |
Definition at line 40 of file mitkPixelType.h.
| mitk::PixelType::PixelType | ( | const std::type_info & | aTypeId, |
| int | numberOfComponents = 1, |
||
| ItkIOPixelType | anItkIoPixelType = itk::ImageIOBase::UNKNOWNPIXELTYPE |
||
| ) |
Definition at line 78 of file mitkPixelType.cpp.
References Initialize().
: m_TypeId( &aTypeId ), m_NumberOfComponents( numberOfComponents )
{
Initialize( aTypeId, numberOfComponents, anItkIoPixelType );
}
| mitk::PixelType::PixelType | ( | mitkIpPicType_t | type, |
| int | bpe, | ||
| int | numberOfComponents = 1 |
||
| ) |
Definition at line 83 of file mitkPixelType.cpp.
References Initialize().
: m_Type( type ), m_Bpe( bpe ), m_NumberOfComponents( numberOfComponents )
{
Initialize( type, bpe, numberOfComponents );
}
| mitk::PixelType::PixelType | ( | const mitkIpPicDescriptor * | pic ) |
Definition at line 88 of file mitkPixelType.cpp.
References Initialize().
: m_NumberOfComponents( 1 )
{
if ( pic != NULL )
Initialize( pic->type, pic->bpe );
else
{
m_TypeId = NULL;
// itkExceptionMacro("pic.IsNull() has no pixel type.");
}
}
| mitk::PixelType::PixelType | ( | const mitk::PixelType & | aPixelType ) |
Definition at line 73 of file mitkPixelType.cpp.
References GetNumberOfComponents(), and GetTypeId().
{
Initialize( *aPixelType.GetTypeId(), aPixelType.GetNumberOfComponents() );
}
| mitk::PixelType::PixelType | ( | ) |
Definition at line 68 of file mitkPixelType.cpp.
: m_TypeId( NULL ), m_Type( mitkIpPicUnknown ), m_Bpe( 0 ), m_NumberOfComponents( 1 )
{
}
| virtual mitk::PixelType::~PixelType | ( | ) | [inline, virtual] |
Definition at line 141 of file mitkPixelType.h.
{}
| int mitk::PixelType::GetBitsPerComponent | ( | ) | const [inline] |
Get the number of bits per components.
Definition at line 106 of file mitkPixelType.h.
Referenced by mitkPixelTypeTest(), operator=(), and mitkCompressedImageContainerTestClass::Test().
{
return m_BitsPerComponent;
}
| int mitk::PixelType::GetBpe | ( | ) | const [inline] |
Get the number of bits per element (of an element)
A vector of double with three components will return 8*sizeof(double)*3.
Definition at line 89 of file mitkPixelType.h.
Referenced by QmitkSlicesInterpolator::AcceptAllInterpolations(), mitk::ImageDataItem::ImageDataItem(), mitkPixelTypeTest(), operator=(), mitk::LevelWindow::SetAuto(), mitk::CompressedImageContainer::SetImage(), and mitkCompressedImageContainerTestClass::Test().
{
return m_Bpe;
}
| virtual const char* mitk::PixelType::GetClassName | ( | ) | const [virtual] |
| std::string mitk::PixelType::GetItkTypeAsString | ( | ) | const |
Get the typename of the ITK-type representing an element as a human-readable string.
Definition at line 358 of file mitkPixelType.cpp.
Referenced by mitkPixelTypeTest().
{
if (GetItkTypeId()==NULL)
{
return "unknown";
}
else
{
return GetItkTypeId()->name();
}
}
| const std::type_info* mitk::PixelType::GetItkTypeId | ( | ) | const [inline] |
Get the type_info of the ITK-type representing an element. Can be NULL in case the ITK-type is unknown.
Definition at line 64 of file mitkPixelType.h.
Referenced by mitkPixelTypeTest(), operator=(), and mitk::ImageWriter::WriteByITK().
{
return m_ItkTypeId;
}
| int mitk::PixelType::GetNumberOfComponents | ( | ) | const [inline] |
Get the number of components of which each element consists.
Each pixel can consist of multiple components, e.g. RGB.
Definition at line 98 of file mitkPixelType.h.
Referenced by mitk::NodePredicateDimension::CheckNode(), mitkPixelTypeTest(), operator=(), PixelType(), mitkCompressedImageContainerTestClass::Test(), QmitkImageStatistics::UpdateStatistics(), and mitk::ImageWriter::WriteByITK().
{
return m_NumberOfComponents;
}
| mitkIpPicType_t mitk::PixelType::GetType | ( | ) | const [inline] |
Get the mitkIpPicType_t of the scalar (!) component type. Each element may contain m_NumberOfComponents (more than one) of these scalars.
Definition at line 75 of file mitkPixelType.h.
Referenced by mitk::ImageDataItem::ImageDataItem(), operator=(), and mitk::LevelWindow::SetAuto().
{
return m_Type;
}
| const std::type_info* mitk::PixelType::GetTypeId | ( | ) | const [inline] |
Get the type_info of the scalar (!) type. Each element may contain m_NumberOfComponents (more than one) of these scalars.
Definition at line 55 of file mitkPixelType.h.
Referenced by mitk::BoundingObjectCutter::GenerateInputRequestedRegion(), mitk::Image::Initialize(), CompareImageSliceTestHelper::ItkImageSwitch(), mitkPixelTypeTest(), operator=(), PixelType(), and mitkCompressedImageContainerTestClass::Test().
{
return m_TypeId;
}
| void mitk::PixelType::Initialize | ( | const std::type_info & | aTypeId, |
| int | numberOfCompontents = 1, |
||
| ItkIOPixelType | anItkIoPixelType = itk::ImageIOBase::UNKNOWNPIXELTYPE |
||
| ) |
Definition at line 174 of file mitkPixelType.cpp.
References N_VEC, and SET_TYPE.
Referenced by mitk::ItkImageFileReader::GenerateData(), mitk::Image::Initialize(), and PixelType().
{
m_TypeId = &aTypeId;
m_NumberOfComponents = numberOfComponents;
if(m_NumberOfComponents == 1)
m_ItkTypeId = &aTypeId;
else
m_ItkTypeId = NULL;
SET_TYPE(double, mitkIpPicFloat)
SET_TYPE(float, mitkIpPicFloat)
SET_TYPE(long, mitkIpPicInt)
SET_TYPE(unsigned long, mitkIpPicUInt)
SET_TYPE(int, mitkIpPicInt)
SET_TYPE(unsigned int, mitkIpPicUInt)
SET_TYPE(short, mitkIpPicInt)
SET_TYPE(unsigned short, mitkIpPicUInt)
SET_TYPE(char, mitkIpPicInt)
SET_TYPE(unsigned char, mitkIpPicUInt)
if ( *m_TypeId == typeid( itk::DiffusionTensor3D<float> ) )
{
m_TypeId = & typeid( float );
m_NumberOfComponents *= 6;
m_Type = mitkIpPicFloat;
m_Bpe = sizeof(float) * 8 * m_NumberOfComponents;
m_ItkTypeId = &typeid( itk::DiffusionTensor3D<float> );
}
else if ( *m_TypeId == typeid( itk::DiffusionTensor3D<double> ) )
{
m_TypeId = & typeid( double );
m_NumberOfComponents *= 6;
m_Type = mitkIpPicFloat;
m_Bpe = sizeof(double) * 8 * m_NumberOfComponents;
m_ItkTypeId = &typeid( itk::DiffusionTensor3D<double> );
}
else if ( *m_TypeId == typeid( itk::RGBPixel<unsigned char> ) )
{
m_Type = mitkIpPicUInt;
m_NumberOfComponents = 3;
m_Bpe = sizeof(unsigned char) * 8 * m_NumberOfComponents;
m_ItkTypeId = &typeid( itk::RGBPixel<unsigned char> );
}
else if ( *m_TypeId == typeid( itk::RGBAPixel<unsigned char> ) )
{
m_Type = mitkIpPicUInt;
m_NumberOfComponents = 4;
m_Bpe = sizeof(unsigned char) * 8 * m_NumberOfComponents;
m_ItkTypeId = &typeid( itk::RGBAPixel<unsigned char> );
}
else
{
bool found = false;
// the following lines allow for fixed-size vector images up to a certain size limit
// (commented out for shorter compile times)
//HUNDRED_VECS(000)
//HUNDRED_VECS(100)
//HUNDRED_VECS(200)
//HUNDRED_VECS(300)
//HUNDRED_VECS(400)
//HUNDRED_VECS(500)
//HUNDRED_VECS(600)
//HUNDRED_VECS(700)
// allow for fixed-size vectors of specific length
// (inspired by itkPointshell.cpp, precompiled q-ball configs)
//TEN_VECS(0)
//N_VEC(11)
//N_VEC(12)
if(false){}
N_VEC(3)
N_VEC(6)
N_VEC(42)
N_VEC(92)
N_VEC(162)
N_VEC(252)
N_VEC(362)
N_VEC(492)
N_VEC(642)
N_VEC(812)
N_VEC(1002)
if(!found)
itkExceptionMacro( "Pixel type currently not supported." );
}
m_BitsPerComponent = m_Bpe / m_NumberOfComponents;
}
| void mitk::PixelType::Initialize | ( | mitkIpPicType_t | type, |
| int | bpe, | ||
| int | numberOfComponents = 1 |
||
| ) |
Definition at line 263 of file mitkPixelType.cpp.
References int().
{
m_Type = type;
m_Bpe = bpe;
m_NumberOfComponents = numberOfComponents;
switch ( type )
{
case mitkIpPicUnknown:
m_TypeId = &typeid( void* );
break;
case mitkIpPicBool:
m_TypeId = &typeid( bool );
m_Bpe = sizeof(bool) * 8 * numberOfComponents;
break;
case mitkIpPicASCII:
m_TypeId = &typeid( char );
m_Bpe = sizeof(char) * 8 * numberOfComponents;
break;
case mitkIpPicInt:
switch ( bpe / numberOfComponents )
{
case 8:
m_TypeId = &typeid( char );
break;
case 16:
m_TypeId = &typeid( short );
break;
case 32:
m_TypeId = &typeid( int );
break;
case 64:
m_TypeId = &typeid( long );
break;
default:
m_TypeId = NULL;
itkExceptionMacro( "Pixel type currently not supported." );
}
break;
case mitkIpPicUInt:
switch ( bpe / numberOfComponents )
{
case 8:
m_TypeId = &typeid( unsigned char );
break;
case 16:
m_TypeId = &typeid( unsigned short );
break;
case 24:
m_TypeId = &typeid( unsigned char );
m_NumberOfComponents = numberOfComponents = 3;
break;
case 32:
m_TypeId = &typeid( unsigned int );
break;
case 64:
m_TypeId = &typeid( unsigned long );
break;
default:
m_TypeId = NULL;
itkExceptionMacro( "Pixel type currently not supported." );
}
break;
case mitkIpPicFloat:
switch ( bpe / numberOfComponents )
{
case 32:
m_TypeId = &typeid( float );
break;
case 64:
m_TypeId = &typeid( double );
break;
default:
m_TypeId = NULL;
itkExceptionMacro( "Pixel type currently not supported." );
}
break;
case mitkIpPicNonUniform:
m_TypeId = &typeid( void* );
break;
case mitkIpPicTSV:
m_TypeId = &typeid( void* );
break;
default:
m_TypeId = NULL;
itkExceptionMacro( "Pixel type currently not supported." );
break;
}
m_BitsPerComponent = m_Bpe / numberOfComponents;
if(m_NumberOfComponents == 1)
m_ItkTypeId = m_TypeId;
else
m_ItkTypeId = NULL;
}
| bool mitk::PixelType::operator!= | ( | const std::type_info & | typeId ) | const |
Definition at line 129 of file mitkPixelType.cpp.
References operator==().
{
return !(this->operator==(typeId));
}
| bool mitk::PixelType::operator!= | ( | const PixelType & | rhs ) | const |
Definition at line 117 of file mitkPixelType.cpp.
References operator==().
{
return !(this->operator==(rhs));
}
Definition at line 118 of file mitkPixelType.h.
References GetBitsPerComponent(), GetBpe(), GetItkTypeId(), GetNumberOfComponents(), GetType(), and GetTypeId().
{
m_TypeId=aPixelType.GetTypeId();
m_ItkTypeId=aPixelType.GetItkTypeId();
m_Type=aPixelType.GetType();
m_Bpe=aPixelType.GetBpe();
m_NumberOfComponents = aPixelType.GetNumberOfComponents();
m_BitsPerComponent = aPixelType.GetBitsPerComponent();
return *this;
}
| bool mitk::PixelType::operator== | ( | const PixelType & | rhs ) | const |
Definition at line 99 of file mitkPixelType.cpp.
References MITK_INFO.
{
MITK_INFO << "operator==" << std::endl;
MITK_INFO << "m_Type = " << m_Type << " " << rhs.m_Type << std::endl;
MITK_INFO << "m_Bpe = " << m_Bpe << " " << rhs.m_Bpe << std::endl;
MITK_INFO << "m_NumberOfComponents = " << m_NumberOfComponents << " " << rhs.m_NumberOfComponents << std::endl;
MITK_INFO << "m_BitsPerComponent = " << m_BitsPerComponent << " " << rhs.m_BitsPerComponent << std::endl;
return (
*(this->m_TypeId) == *(rhs.m_TypeId)
&& this->m_Type == rhs.m_Type
&& this->m_Bpe == rhs.m_Bpe
&& this->m_NumberOfComponents == rhs.m_NumberOfComponents
&& this->m_BitsPerComponent == rhs.m_BitsPerComponent
);
}
| bool mitk::PixelType::operator== | ( | const std::type_info & | typeId ) | const |
Definition at line 122 of file mitkPixelType.cpp.
{
if (GetItkTypeId() == NULL)
return false;
return (*GetItkTypeId() == typeId);
}
1.7.2