<div dir="ltr"><div> I don't have a label image to use the example: <a href="https://github.com/blowekamp/itkOBBLabelMap/blob/master/test/itkOBBExample.cxx" target="_blank"><font color="#0066cc">https://github.com/blowekamp/</font><font color="#0066cc">itkOBBLabelMap/blob/master/</font><font color="#0066cc">test/itkOBBExample.cxx</font></a></div>
<div> </div><div>However, I used to write the main method ... where only a binary image is used as input. </div><div> </div><div>Thanks!</div><div>EM </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Nov 12, 2013 at 2:26 PM, elhadj meljane <span dir="ltr"><<a href="mailto:elhadj.meljane@gmail.com" target="_blank">elhadj.meljane@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra">Hello!</div><div class="gmail_extra">I am using your github extension (I included the files manually in my project)... and wrote the main method below. The code compile but at the run time I got the error: </div>
<div class="gmail_extra"><br>"program.exe has stopped working. A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available. "</div><div class="gmail_extra">
When I click to debug with MS Visual Studio, I got the warning: <br>Unhandled exception at 0x01... in program.exe: 0xC00000005: Acces violation reading location 0x18...</div><div class="gmail_extra"> </div><div class="gmail_extra">
Here's the code: </div><div class="gmail_extra"> </div><div class="gmail_extra"><font face="Consolas">
<font color="#0000ff"><font color="#0000ff"><font color="#0000ff"></font></font></font></font><p><font face="Consolas"><font color="#0000ff"><font color="#0000ff"><font color="#0000ff">#include</font></font></font><font><font> </font></font><font color="#a31515"><font color="#a31515"><font color="#a31515">"itkImageFileReader.h"</font></font></font></font></p>
<font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas">
</font></font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">#include</font></font></font><font face="Consolas"><font face="Consolas"> </font></font><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas">"itkImageFileWriter.h"</font></font></font></p>
<font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas">
</font></font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">#include</font></font></font><font face="Consolas"><font face="Consolas"> </font></font><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas">"itkBoundingBoxImageLabelMapFilter.h"</font></font></font></p>
<font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas">
</font></font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">#include</font></font></font><font face="Consolas"><font face="Consolas"> </font></font><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas">"itkAttributeImageLabelObject.h"</font></font></font></p>
<font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas">
</font></font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">#include</font></font></font><font face="Consolas"><font face="Consolas"> </font></font><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas">"itkBinaryImageToShapeLabelMapFilter.h"</font></font></font><font face="Consolas"><font face="Consolas"> </font></font></p>
<div class="im">
<font face="Consolas"><font face="Consolas">
<p> </p>
</font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">const</font></font></font><font face="Consolas"><font face="Consolas"> </font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">unsigned</font></font></font><font face="Consolas"><font face="Consolas"> </font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">int</font></font></font><font face="Consolas"><font face="Consolas"> Dimension = 2;</font></font></p>
<font face="Consolas"><font face="Consolas">
</font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">typedef</font></font></font><font face="Consolas"><font face="Consolas"> </font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">unsigned</font></font></font><font face="Consolas"><font face="Consolas"> </font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">char</font></font></font><font face="Consolas"><font face="Consolas"> LabelPixelType;</font></font></p>
<font face="Consolas"><font face="Consolas">
</font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">typedef</font></font></font><font face="Consolas"><font face="Consolas"> itk::Image< LabelPixelType, Dimension > LabelImageType;</font></font></p>
<font face="Consolas"><font face="Consolas">
</font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">typedef</font></font></font><font face="Consolas"><font face="Consolas"> </font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">unsigned</font></font></font><font face="Consolas"><font face="Consolas"> </font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">char</font></font></font><font face="Consolas"><font face="Consolas"> OutputPixelType;</font></font></p>
<font face="Consolas"><font face="Consolas">
</font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">typedef</font></font></font><font face="Consolas"><font face="Consolas"> itk::Image< OutputPixelType, Dimension > OutputImageType;</font></font></p>
<font face="Consolas"><font face="Consolas">
</font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">typedef</font></font></font><font face="Consolas"><font face="Consolas"> itk::ImageFileReader< OutputImageType > ReaderType;</font></font></p>
<font face="Consolas"><font face="Consolas">
</font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">typedef</font></font></font><font face="Consolas"><font face="Consolas"> itk::ImageFileWriter< OutputImageType > WriterType;</font></font></p>
<font face="Consolas"><font face="Consolas">
</font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">typedef</font></font></font><font face="Consolas"><font face="Consolas"> itk::AttributeImageLabelObject< LabelPixelType, Dimension, OutputImageType > LabelObjectAttributeType;</font></font></p>
<font face="Consolas"><font face="Consolas">
</font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">typedef</font></font></font><font face="Consolas"><font face="Consolas"> itk::LabelMap<LabelObjectAttributeType> LabelMapAttributeType;</font></font></p>
<font face="Consolas"><font face="Consolas">
</font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">typedef</font></font></font><font face="Consolas"><font face="Consolas"> itk::BinaryImageToShapeLabelMapFilter </font></font></p>
<font face="Consolas"><font face="Consolas">
<p>                        <OutputImageType, LabelMapAttributeType> LabelMapperAttributeType;</p>
</font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">typedef</font></font></font><font face="Consolas"><font face="Consolas"> itk::LabelMapToLabelImageFilter<LabelMapAttributeType, OutputImageType> LabelMapToLabelImageFilterType;</font></font></p>
<font face="Consolas"><font face="Consolas">
</font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">typedef</font></font></font><font face="Consolas"><font face="Consolas"> itk::BoundingBoxImageLabelMapFilter<LabelMapAttributeType> BBILabelMapFilter;</font></font></p>
<font face="Consolas"><font face="Consolas">
<p> </p>
<p> </p>
</font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"></font></font></font></div><p><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">int</font></font></font><font face="Consolas"><font face="Consolas"> main( </font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">int</font></font></font><font face="Consolas"><font face="Consolas"> argc, </font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">char</font></font></font><font face="Consolas"><font face="Consolas"> *argv[] )</font></font></p>
<div class="im">
<font face="Consolas"><font face="Consolas">
<p>{</p>
<p>        </p>
<p>        ReaderType::Pointer reader = ReaderType::New();</p>
</font></font></div><p><font face="Consolas"><font face="Consolas">        </font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">typedef</font></font></font><font face="Consolas"><font face="Consolas"> itk::ImageFileWriter< OutputImageType > WriterType;</font></font></p>
<font face="Consolas"><font face="Consolas">
<p> </p>
</font></font><p><font face="Consolas"><font face="Consolas">        </font></font><font color="#008000" face="Consolas"><font color="#008000" face="Consolas"><font color="#008000" face="Consolas">//input</font></font></font></p>
<div class="im">
<font color="#008000" face="Consolas"><font color="#008000" face="Consolas"><font color="#008000" face="Consolas">
</font></font></font><font face="Consolas"><font face="Consolas"><p>        reader->SetFileName( argv[1] );</p>
<p>        </p>
</font></font></div><p><font face="Consolas"><font face="Consolas">        </font></font><font color="#008000" face="Consolas"><font color="#008000" face="Consolas"><font color="#008000" face="Consolas">//label image </font></font></font></p>
<div class="im">
<font color="#008000" face="Consolas"><font color="#008000" face="Consolas"><font color="#008000" face="Consolas">
</font></font></font><font face="Consolas"><font face="Consolas"><p>        LabelMapperAttributeType::Pointer labelerAttribute = LabelMapperAttributeType::New();</p>
<p>        labelerAttribute->SetInput( reader->GetOutput() );</p>
</font></font><p><font face="Consolas"><font face="Consolas">        labelerAttribute->SetComputePerimeter( </font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">false</font></font></font><font face="Consolas"><font face="Consolas"> ); </font></font></p>
</div><font face="Consolas"><font face="Consolas">
<p>        labelerAttribute->SetOutputBackgroundValue(0); </p>
<p>        labelerAttribute->Update();                </p>
<p>        LabelMapAttributeType::Pointer labelMapAttribute = labelerAttribute->GetOutput(); </p>
<p>        </p>
</font></font><p><font face="Consolas"><font face="Consolas">        </font></font><font color="#008000" face="Consolas"><font color="#008000" face="Consolas"><font color="#008000" face="Consolas">//extract the component with the label 1</font></font></font></p>
<div class="im">
<font color="#008000" face="Consolas"><font color="#008000" face="Consolas"><font color="#008000" face="Consolas">
</font></font></font><font face="Consolas"><font face="Consolas"><p>        BBILabelMapFilter::Pointer toBBILabelMap = BBILabelMapFilter::New();</p>
<p> toBBILabelMap->SetInput(labelMapAttribute);</p>
<p> toBBILabelMap->Update();</p>
</font></font><p><font face="Consolas"><font face="Consolas"> </font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">const</font></font></font><font face="Consolas"><font face="Consolas"> LabelObjectAttributeType* labelObjectAttribute = toBBILabelMap->GetOutput()->GetLabelObject(1);</font></font></p>
<font face="Consolas"><font face="Consolas">
<p>        </p>
</font></font></div><p><font face="Consolas"><font face="Consolas">        </font></font><font color="#008000" face="Consolas"><font color="#008000" face="Consolas"><font color="#008000" face="Consolas">//write </font></font></font></p>
<font color="#008000" face="Consolas"><font color="#008000" face="Consolas"><font color="#008000" face="Consolas">
</font></font></font><font face="Consolas"><font face="Consolas"><p>        WriterType::Pointer writer = WriterType::New();</p>
</font></font><p><font face="Consolas"><font face="Consolas">        writer->SetFileName( </font></font><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas"><font color="#a31515" face="Consolas">"copy_input.jpg"</font></font></font><font face="Consolas"><font face="Consolas"> );</font></font></p>
<font face="Consolas"><font face="Consolas">
<p>        writer->SetInput( reader->GetOutput());</p>
<p>        writer->Update();</p>
<p>        </p>
</font></font><p><font face="Consolas"><font face="Consolas">        </font></font><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas"><font color="#0000ff" face="Consolas">return</font></font></font><font face="Consolas"><font face="Consolas"> 0;</font></font></p>
<font face="Consolas"><font face="Consolas">
<p>}</p>
<p> </p>
<p> </p>
<p> </p></font></font><br></div><div><div class="h5"><div class="gmail_extra"> </div><div class="gmail_extra"> </div><div class="gmail_extra"><br> </div><div class="gmail_quote">On Tue, Nov 12, 2013 at 1:53 PM, Bradley Lowekamp <span dir="ltr"><<a href="mailto:blowekamp@mail.nih.gov" target="_blank">blowekamp@mail.nih.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div>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" target="_blank">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" target="_blank">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><div><div>On Nov 12, 2013, at 1:43 PM, elhadj meljane <<a href="mailto:elhadj.meljane@gmail.com" target="_blank">elhadj.meljane@gmail.com</a>> wrote:</div>
<br></div></div><blockquote type="cite"><div><div><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></div></div>
_______________________________________________<br>Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>Kitware offers ITK Training Courses, for more information visit:<br><a href="http://kitware.com/products/protraining.php" target="_blank">http://kitware.com/products/protraining.php</a><br><br>Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.itk.org/mailman/listinfo/insight-developers" target="_blank">http://www.itk.org/mailman/listinfo/insight-developers</a><br>
</blockquote></div><br></div></div></blockquote></div><div class="gmail_extra"><br></div></div></div></div>
</blockquote></div><br></div>