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

Dženan Zukić dzenanz at gmail.com
Tue Nov 21 12:46:17 EST 2017


Hi Elli,

can you repost on discourse <https://discourse.itk.org/>? We have moved
there.

Regards,
Dženan

On Tue, Nov 21, 2017 at 10:12 AM, Pfaehler, EAG (ngmb) <
e.a.g.pfaehler at umcg.nl> wrote:

> 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 = LabelImageToShapeLabelMapFilte
> rType::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.
>
> The ITK community is transitioning from this mailing list to
> discourse.itk.org. Please join us there!
> ______________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-developers/attachments/20171121/e1cbdb37/attachment.html>


More information about the Insight-developers mailing list