[ITK-users] BinaryImageToShapeLabelMapFilter problem
Zein Salah
zeinsalah at gmail.com
Mon Dec 8 10:11:06 EST 2014
Hi,
I am using the BinaryImageToShapeLabelMapFilter to label connected
component in a binaty image. I recycled some code as follows:
typedef unsigned long LabelType;
typedef itk::ShapeLabelObject< LabelType, 3 > LabelObjectType;
typedef itk::LabelMap< LabelObjectType > LabelMapType;
typedef itk::BinaryImageToShapeLabelMapFilter< BinaryImageType,
LabelMapType > ConverterType;
ConverterType::Pointer converter = ConverterType::New();
converter->SetInput(m_SegmentedImage);
converter->SetInputForegroundValue(255);
converter->Update();
LabelMapType::Pointer labelMap = converter->GetOutput();
MarkerPositions detectedMarkers;
for( unsigned int label=0;
label<labelMap->GetNumberOfLabelObjects(); label++ )
{
const LabelObjectType * labelObject = labelMap->GetNthLabelObject(label);
ImageType::PointType point = labelObject->GetCentroid();
std::cout << label << "\t" << labelObject->GetPhysicalSize() <<
" at: " << point[0] << "," << point[1] << "," << point[2] <<
std::endl;
}
The code actually generates some labels (for the image I used, it
generates 35 labels).
The thing I could not understand is that the centroids of the labeled
object do not correspond
to components in the image. I.e., when I take one centroid and select the point
in the image, in most, if not all, cases it is an empty area. Are elements in
a label map no more related to there position in the image? or I am
missing some point here??
Centroids are computed in the pixels coordinates, not physical locations. Right?
thanks,
Zein
More information about the Insight-users
mailing list