[Insight-developers] select an item from a binary image

Bradley Lowekamp blowekamp at mail.nih.gov
Tue Nov 12 13:53:51 EST 2013


Hello,

It appears that you are trying to use some code from my github extension:

https://github.com/blowekamp/itkOBBLabelMap

I am not sure where to begin helping you. You didn't include the run-time error message, and your code fragment is missing key parts. Can you post a minimal compilable example which illustrates the problem? Sometime just narrowing down you code to this part help you figure out your issue.

Do the tests for the extension pass for you?

Are you able to run the example?

https://github.com/blowekamp/itkOBBLabelMap/blob/master/test/itkOBBExample.cxx

Brad


On Nov 12, 2013, at 1:43 PM, elhadj meljane <elhadj.meljane at gmail.com> wrote:

> Hi all, 
> I am trying to use itk to select a component from a binary image. The binary image contains several items and I want to separate them in different images.
>    
> I used the code below but it doesn't work. I got an error message at the run time. It looks from the debugger that the line
>  
> labelerAttribute->Update()
>  
> causes the error. I gave a valid file as input and  checked that ITK reads correctly this file.  I would appreciate your help to fix this!
> 
> #include "itkAttributeImageLabelObject.h"
> 
> const      unsigned int    Dimension = 2;
> typedef  unsigned char LabelPixelType;
> typedef  itk::Image< LabelPixelType, Dimension >  LabelImageType;
> typedef  unsigned char                           OutputPixelType;
> typedef  itk::Image< OutputPixelType, Dimension > OutputImageType;
> typedef   itk::ImageFileReader< OutputImageType > ReaderType;
> typedef   itk::ImageFileWriter<  OutputImageType  > WriterType;
> typedef  itk::AttributeImageLabelObject< LabelPixelType, Dimension, OutputImageType > LabelObjectAttributeType;
> typedef  itk::LabelMap<LabelObjectAttributeType> LabelMapAttributeType;
> typedef  itk::BinaryImageToShapeLabelMapFilter 
>    <OutputImageType, LabelMapAttributeType>  LabelMapperAttributeType;
> typedef  itk::LabelMapToLabelImageFilter<LabelMapAttributeType, OutputImageType> LabelMapToLabelImageFilterType;
> typedef  itk::BoundingBoxImageLabelMapFilter<LabelMapAttributeType> BBILabelMapFilter;
> typedef   itk::ImageFileWriter<  OutputImageType  > WriterType;
> 
> ReaderType::Pointer reader = ReaderType::New();
> 
> reader->SetFileName( argv[1] );
>  
> LabelMapperAttributeType::Pointer labelerAttribute = LabelMapperAttributeType::New();
> 
> 
> labelerAttribute->SetInput( reader->GetOutput() );
> labelerAttribute->SetComputePerimeter( false ); 
> labelerAttribute->SetOutputBackgroundValue(0); 
> labelerAttribute->Update();
>  
>  
> //select the item with the label 1
> const LabelObjectAttributeType* labelObjectAttribute = toBBILabelMap->GetOutput()->GetLabelObject(1);
> 
> BBILabelMapFilter::Pointer toBBILabelMap =  BBILabelMapFilter::New();
> toBBILabelMap->SetInput(labelMapAttribute);
> toBBILabelMap->Update();
> 
> 
> Thanks.
> Best 
> EM
> 
> _______________________________________________
> 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://www.itk.org/mailman/listinfo/insight-developers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20131112/667aa2ab/attachment.htm>


More information about the Insight-developers mailing list