<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div><br></div><div>It appears that you are trying to use some code from my github extension:</div><div><br></div><div><a href="https://github.com/blowekamp/itkOBBLabelMap">https://github.com/blowekamp/itkOBBLabelMap</a></div><div><br></div><div>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.</div><div><br></div><div>Do the tests for the extension pass for you?</div><div><br></div><div>Are you able to run the example?</div><div><br></div><div><a href="https://github.com/blowekamp/itkOBBLabelMap/blob/master/test/itkOBBExample.cxx">https://github.com/blowekamp/itkOBBLabelMap/blob/master/test/itkOBBExample.cxx</a></div><div><br></div><div>Brad</div><div><br></div><div><br><div><div>On Nov 12, 2013, at 1:43 PM, elhadj meljane <<a href="mailto:elhadj.meljane@gmail.com">elhadj.meljane@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><div dir="ltr"><div>Hi all, <br>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.<br> <br>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 </div>
<div> </div><div>labelerAttribute->Update() </div><div> </div><div>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! </div><p><br>
#include "itkAttributeImageLabelObject.h"</p><p>const unsigned int Dimension = 2;<br>typedef unsigned char LabelPixelType;<br>typedef itk::Image< LabelPixelType, Dimension > LabelImageType;<br>
typedef unsigned char OutputPixelType;<br> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br>typedef itk::ImageFileReader< OutputImageType > ReaderType;<br>typedef itk::ImageFileWriter< OutputImageType > WriterType;<br>
typedef itk::AttributeImageLabelObject< LabelPixelType, Dimension, OutputImageType > LabelObjectAttributeType;<br> typedef itk::LabelMap<LabelObjectAttributeType> LabelMapAttributeType;<br>typedef itk::BinaryImageToShapeLabelMapFilter <br>
<OutputImageType, LabelMapAttributeType> LabelMapperAttributeType;<br>typedef itk::LabelMapToLabelImageFilter<LabelMapAttributeType, OutputImageType> LabelMapToLabelImageFilterType;<br> typedef itk::BoundingBoxImageLabelMapFilter<LabelMapAttributeType> BBILabelMapFilter;<br>
typedef itk::ImageFileWriter< OutputImageType > WriterType;</p><p>ReaderType::Pointer reader = ReaderType::New();</p><p>reader->SetFileName( argv[1] );<br> <br>LabelMapperAttributeType::Pointer labelerAttribute = LabelMapperAttributeType::New();</p>
<div><br>labelerAttribute->SetInput( reader->GetOutput() );<br>labelerAttribute->SetComputePerimeter( false ); <br> labelerAttribute->SetOutputBackgroundValue(0); <br>labelerAttribute->Update();</div><div> </div>
<div> </div><div>//select the item with the label 1</div><p>const LabelObjectAttributeType* labelObjectAttribute = toBBILabelMap->GetOutput()->GetLabelObject(1);</p><p>BBILabelMapFilter::Pointer toBBILabelMap = BBILabelMapFilter::New();<br>
toBBILabelMap->SetInput(labelMapAttribute);<br>toBBILabelMap->Update();</p><p><br>Thanks.<br>Best <br><span><font color="#888888">EM </font></span></p></div>
_______________________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://kitware.com/products/protraining.php<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-developers<br></blockquote></div><br></div></body></html>