[ITK-dev] Problem calculating oriented bounding box, itk::ShapeLabelObject

Pfaehler, EAG (ngmb) e.a.g.pfaehler at umcg.nl
Tue Nov 21 10:12:44 EST 2017


Dear all,

I need the size of the oriented bounding box of a mask.
I created a shape label object and extracted already some attributes (like nr. of pixels etc), what works pretty fine.
Now I wanted to get the size of the oriented bounding box. But whatever I do and no matter which object I use, I always get the result [0, 0, 0]
Is there a trick?

Thanks a lot for your answer.

Regards

Elli

My code:


        typedef itk::CastImageFilter<ImageType, intImage> CastFilterType;
        typedef itk::CastImageFilter<ImageType, uCharImage> uCharCastFilterType;
        typedef itk::ConnectedComponentImageFilter <intImage, intImage> ConnectedComponentFilterType;
        typedef itk::LabelImageToShapeLabelMapFilter<intImage> LabelImageToShapeLabelMapFilterType;

        typedef int LabelType;
        typedef itk::ShapeLabelObject<LabelType, R> ShapeLabelObjectType;
        typedef itk::LabelMap<ShapeLabelObjectType> LabelMapType;
    typename ConnectedComponentFilterType::Pointer connectedComponentImageFilter = ConnectedComponentFilterType::New();
    connectedComponentImageFilter->SetInput(castFilter->GetOutput());
    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->SetComputePerimeter(true);
    labelImageToShapeLabelMapFilter->Update();

    LabelMapType *labelMap = labelImageToShapeLabelMapFilter->GetOutput();
    labelMap->Update();
    /*!
    For every connected component a labelObject is created
    Because we are only interested in the object with the label one, we check the label number
    */
    for(unsigned int n = 0; n < labelMap->GetNumberOfLabelObjects(); n++){
        ShapeLabelObjectType *labelObject = labelMap->GetNthLabelObject(n);
        int labelNr = labelObject->GetLabel();
        if(labelNr ==1){
#ifdef _WIN32
            volume = labelObject->GetPhysicalSize();
            principalMoments = labelObject->GetPrincipalMoments();
            nrPixels = labelObject->GetNumberOfPixels();
            surface = labelObject->GetNumberOfPixelsOnBorder()*imageSpacingX*imageSpacingY*imageSpacingZ;
            std::cout << "nr Pixels border" << labelObject->GetOrientedBoundingBoxOrigin() << std::endl;
________________________________
De inhoud van dit bericht is vertrouwelijk en alleen bestemd voor de geadresseerde(n). Anderen dan de geadresseerde(n) mogen geen gebruik maken van dit bericht, het niet openbaar maken of op enige wijze verspreiden of vermenigvuldigen. Het UMCG kan niet aansprakelijk gesteld worden voor een incomplete aankomst of vertraging van dit verzonden bericht.

The contents of this message are confidential and only intended for the eyes of the addressee(s). Others than the addressee(s) are not allowed to use this message, to make it public or to distribute or multiply this message in any way. The UMCG cannot be held responsible for incomplete reception or delay of this transferred message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-developers/attachments/20171121/85718620/attachment.html>


More information about the Insight-developers mailing list