<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:'Times New Roman', Times, serif;" dir="ltr">
<p>Dear ITK users,</p>
<p><br>
</p>
<p>After using the BinaryFillHoleFilter for a 3D Dicom image (see attached), I adopted the <span>BinaryContourImageFilter in order to obtain the contour of the image.  However, the thikness of the contour is very big. My goal is to obtain 1 pixel of thickness.</span></p>
<p><span><br>
</span></p>
<p><span>The fragment of my code is :</span></p>
<p><span><br>
</span></p>
<p><span>------------------------------------------------------</span></p>
<p><span></p>
<div>#include "itkImage.h"</div>
<div>#include "itkImageFileReader.h"</div>
<div>#include "itkImageFileWriter.h"</div>
<div>#include "itkRescaleIntensityImageFilter.h"</div>
<div>#include "itkCastImageFilter.h"</div>
<div>#include "itkCannyEdgeDetectionImageFilter.h"</div>
<div>#include <itkBinaryContourImageFilter.h></div>
<div>#include <vtkImageData.h></div>
<div>#include <vtkExtractVOI.h></div>
<div>#include <itkLabelToRGBImageFilter.h></div>
<div>#include <itkImageToVTKImageFilter.h></div>
<div>#include <itkVTKImageToImageFilter.h></div>
<div>#include <vtkSmartPointer.h></div>
<div><br>
</div>
<div>int main(int argc, char **argv)</div>
<div>{</div>
<br>
</span>
<p></p>
<p><span></p>
<div>       const unsigned int     Dimension = 3;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>typedef unsigned char<span class="Apple-tab-span" style="white-space:pre">
</span>InputPixelType;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>typedef unsigned char  OutputPixelType;</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>typedef itk::Image<InputPixelType, Dimension>  InputImageType;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>typedef itk::Image<OutputPixelType, Dimension> OutputImageType;</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>typedef itk::ImageFileReader< InputImageType > ReaderType;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>ReaderType::Pointer reader = ReaderType::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>reader->SetFileName("BinaryFillHoleImage.mha");</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>reader->Update();</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>//Slice by Slice Binary Contour</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>// Binary Contour Filter</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>typedef itk::BinaryContourImageFilter <InputImageType, InputImageType > binaryContourImageFilterType;</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>binaryContourImageFilterType::Pointer binaryContourFilter = binaryContourImageFilterType::New ();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>binaryContourFilter->SetInput(reader->GetOutput());</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>binaryContourFilter->SetFullyConnected(1); // true makes thicker contours</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>binaryContourFilter->SetBackgroundValue(0);</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>binaryContourFilter->SetForegroundValue(255); // the value of your binary mask</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>binaryContourFilter->Update();</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>typedef itk::RescaleIntensityImageFilter< InputImageType, InputImageType > RescaleType;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>RescaleType::Pointer rescaler = RescaleType::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>rescaler->SetInput( binaryContourFilter->GetOutput() );</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>rescaler->SetOutputMinimum( 0 );</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>rescaler->SetOutputMaximum( 255 );</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>typedef itk::CastImageFilter< InputImageType, OutputImageType > FilterType;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>FilterType::Pointer filter = FilterType::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>filter->SetInput( rescaler->GetOutput() );</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>// Save the contour</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>typedef itk::ImageFileWriter<OutputImageType> WriterType;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>WriterType::Pointer writer = WriterType::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>writer->SetFileName("Cannybinarycontour.mha");</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>writer->SetInput(filter->GetOutput());</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>try{</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>writer->Update();</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>catch(itk::ExceptionObject &e)</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>std::cerr << e << std::endl;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>}</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>}</div>
<div><br>
</div>
<div>    return EXIT_SUCCESS;</div>
<div>}</div>
<br>
</span>
<p></p>
<p></p>
<p style="font-family: "Times New Roman", Times, serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
------------------------------------------------------</p>
<div><br>
</div>
<p style="font-family: "Times New Roman", Times, serif, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
</p>
Thank you in advance.
<p></p>
<p><br>
</p>
<p>Best regards,</p>
<p><br>
</p>
<div id="Signature"><font size="3" face="Garamond">Abdelkhalek Bakkari</font>
<div><span style="line-height:14px"><font size="3" face="Garamond">Ph.D candidate in Computer Science</font></span></div>
<div><span style="line-height:20.82666778564453px; background-color:rgb(255,255,255)"><font face="Garamond" size="3">Institute of Applied Computer Science</font></span></div>
<div><span style="line-height:18.399999618530273px"><font face="Garamond" size="3">Lodz University of Technology, Poland</font></span></div>
<div><span style="line-height:18.399999618530273px"><font face="Garamond" size="3"><br>
</font></span></div>
<div><br>
</div>
</div>
</div>
</body>
</html>