[Insight-users] shape label map trouble

Robert.Atwood at diamond.ac.uk Robert.Atwood at diamond.ac.uk
Fri May 10 10:57:20 EDT 2013


Hi, 
I found that the example in the paper does not match the example in the code. The example in the code works correctly 


> -----Original Message-----
> From: insight-users-bounces at itk.org [mailto:insight-users-
> bounces at itk.org] On Behalf Of Robert.Atwood at diamond.ac.uk
> Sent: 30 April 2013 17:59
> To: insight-users at itk.org
> Subject: [Insight-users] shape label map trouble
> 
> Hi, everyone and Gaetan:
> 
> I was recoding some old itk applets I did before itk label map was
> introduced to use label map  and shape label object classes, I followed
> the example in Gaetan's paper
> http://hdl.handle.net/1926/584
> 
> and used itk3.2 to try to be sure of compatibility and avoid issues of
> updating my old code too.
> 
> However, I find 535 ojects but they all have size of zero.
> Somehow , the very simple example, translated for my code, virtually
> nothing changed except that the input is at the end of another pipeline
> , the objects always have zero size and centroid.
> The label map output image looks correct.
> 
> Thanks
> Robert
> 
> 
> 
> .... page 26 of the paper....
> 
> typedef itk::ShapeLabelMapFilter< LabelMapType > ShapeFilterType;
> ShapeFilterType::Pointer shape = ShapeFilterType::New();
> shape->SetInput( converter->GetOutput() ); Update();
> LabelMapType::Pointer labelMap = converter->GetOutput(); for( unsigned
> int label=1; label<=labelMap->GetNumberOfLabelObjects(); label++ ) { //
> we don't need a SmartPointer of the label object here, because the
> reference is kept in // in the label map.
> const LabelObjectType * labelObject = labelMap->GetLabelObject( label
> ); std::cout << label << "\t" << labelObject->GetPhysicalSize() << "\t"
> << labelObject->GetCentroid() }
> 
> 
> 
> 
> Translated for my code:
> 
> 220   makelabel->SetInputForegroundValue(1);
> 221   std::cout << makelabel << std::endl; // debugging .. dump the
> object
> 222
> 223   /* set the pipeline for finding the shapes */
> 224   std::cerr << "Now finding labelled components" << std::endl;
> 225   makelabel->SetInput(output);
> 226   getshapes->SetInput(makelabel->GetOutput());
> 227
> 228   try {
> 229       getshapes->Update();
> 230   }catch( itk::ExceptionObject & exp ) {
> 231      std::cerr << "ERROR: itkException caught during getshapes
> update !" << std::endl;
> 232      std::cerr << exp << std::endl;
> 233      std::cerr << "getshapes: " << std::endl << getshapes<<
> std::endl;
> 234      exit(0);
> 235   }
> 236
> 237   /* assign label map for convenience */
> 238
> 239   labelmap=makelabel->GetOutput();
> 240
> 241   std::cout<< " Number of Objects Found:  " << labelmap-
> >GetNumberOfLabelObjects() << std::endl;
> 242
> 243   //for (onum=1;onum<labelmap->GetNumberOfLabelObjects(); onum++)
> 244   for (onum=1;onum<3; onum++) /* degugging .. just stop after a
> couple of objects */
> 245   {
> 246      const ShapeType * cshape=labelmap->GetLabelObject(onum); /* I
> tried using predefined smartpoitner, same result*/
> 247      std::cout<< onum<<" "<< cshape->GetPhysicalSize() << " "<<
> cshape->GetCentroid() << std::endl;
> 248      //std::cout << cshape << std::endl;
> 249      cshape->Print(std::cout);
> 250
> 251   }
> 252
> 253   /* make an image of the labels */
> 254   l2label->SetInput(makelabel->GetOutput());
> 255   mwriter1->SetInput(l2label->GetOutput());
> 256   mwriter1->SetFileName("labelmap.tif");
> 257   mwriter1->Update();
> 
> 
>   ____________________
> 
>   Dr. Robert C. Atwood
>   Senior Support Scientist
>   Beamline I12-JEEP
>   The Joint Engineering and Environmental Processing Beamline
>   Diamond Light Source
>   The Harwell Science and Innovation Campus
>   Didcot,OXON
>   OX11 0DE
>   +44 (0) 1235 778 670
> 
> 
> 
> 
> --
> This e-mail and any attachments may contain confidential, copyright and
> or privileged material, and are for the use of the intended addressee
> only. If you are not the intended addressee or an authorised recipient
> of the addressee please notify us of receipt by returning the e-mail
> and do not use, copy, retain, distribute or disclose the information in
> or attached to the e-mail.
> Any opinions expressed within this e-mail are those of the individual
> and not necessarily of Diamond Light Source Ltd.
> Diamond Light Source Ltd. cannot guarantee that this e-mail or any
> attachments are free from viruses and we cannot accept liability for
> any damage which you may sustain as a result of software viruses which
> may be transmitted in or with the message.
> Diamond Light Source Limited (company no. 4375679). Registered in
> England and Wales with its registered office at Diamond House, Harwell
> Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United
> Kingdom
> 
> 
> 
> 
> _____________________________________
> 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://www.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://www.itk.org/mailman/listinfo/insight-users

-- 
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. 
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
 





More information about the Insight-users mailing list