Dear all,
I have a problem creating a mesh.
I have a binary mask containing two (or more) VOIs. I split it up in the different VOIs using the connected component filter and create for each VOI a mesh (see code below). Then I calculate volume and surface iterating over all cells and using an algorithm I wrote. Then I compare volume/surface with the volume and surface I get when I read in each VOI as a separate binary image. But the results are not the same. How can that be? Should the created mesh not always be the same?
Where could be my mistake?
Thanks in advance!
Elli
typename ConnectedComponentFilterType::Pointer connectedComponentImageFilter = ConnectedComponentFilterType::New();
connectedComponentImageFilter->SetFullyConnected(true);
connectedComponentImageFilter->SetInput(mask);
connectedComponentImageFilter->Update();
//With the label image to shape label map filter the mask is converted to a labeled image
typename LabelImageToShapeLabelMapFilterType::Pointer labelImageToShapeLabelMapFilter = LabelImageToShapeLabelMapFilterType::New();
labelImageToShapeLabelMapFilter->SetInput(connectedComponentImageFilter->GetOutput());
labelImageToShapeLabelMapFilter->Update();
LabelMapType *labelMap = labelImageToShapeLabelMapFilter->GetOutput();
using LabelMapToLabelImageFilterType = itk::LabelMapToLabelImageFilter<LabelMapType, ImageType>;
LabelMapToLabelImageFilterType::Pointer labelImageConverter = LabelMapToLabelImageFilterType::New();
labelImageConverter->SetInput(labelMap);
labelImageConverter->Update();
ImageType::Pointer labeledMask = labelImageConverter->GetOutput();
//For every connected component a labelObject is created
for (unsigned int n = 0; n < labelMap->GetNumberOfLabelObjects(); n++) {
ShapeLabelObjectType *labelObject = labelMap->GetNthLabelObject(n);
int labelNr = labelObject->GetLabel();
const PixelType objectValue| = static_cast<PixelType>(1);
meshSource->SetObjectValue(objectValue);
meshSource->SetInput(labeledMask );