int main( int argc, char * argv[] )
{
if( argc < 3 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputImageFile" << std::endl;
return 1;
}
typedef unsigned char InputPixelType;
typedef unsigned char OutputPixelType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName( argv[1] );
writer->SetFileName( argv[2] );
InputImageType, OutputImageType > FilterType;
FilterType::Pointer relabeler = FilterType::New();
relabeler->SetInput( reader->GetOutput() );
writer->SetInput( relabeler->GetOutput() );
writer->Update();
typedef std::vector< itk::SizeValueType > SizesInPixelsType;
const SizesInPixelsType & sizesInPixels
= relabeler->GetSizeOfObjectsInPixels();
SizesInPixelsType::const_iterator sizeItr = sizesInPixels.begin();
SizesInPixelsType::const_iterator sizeEnd = sizesInPixels.end();
std::cout << "Number of pixels per class " << std::endl;
unsigned int kclass = 0;
while( sizeItr != sizeEnd )
{
std::cout << "Class " << kclass << " = " << *sizeItr << std::endl;
++kclass;
++sizeItr;
}
typedef std::vector< float > SizesInPhysicalUnitsType;
const SizesInPhysicalUnitsType sizesInUnits
= relabeler->GetSizeOfObjectsInPhysicalUnits();
SizesInPhysicalUnitsType::const_iterator physicalSizeItr
= sizesInUnits.begin();
SizesInPhysicalUnitsType::const_iterator physicalSizeEnd
= sizesInUnits.end();
std::cout << "Area in Physical Units per class " << std::endl;
unsigned int jclass = 0;
while( physicalSizeItr != physicalSizeEnd )
{
std::cout << "Class " << jclass << " = " << *physicalSizeItr << std::endl;
++jclass;
++physicalSizeItr;
}
return 0;
}