<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hello,
<div class=""><br class="">
</div>
<div class="">I believe that the BinaryCountourImageFilter operates in voxel space so the pixel spacing would not have an effect.</div>
<div class=""><br class="">
</div>
<div class="">I think you are using the wrong metric to determine if the contour is “1 pixel thick”. You need to remember that you are dealing with a 3D space where the contour is a 2-manifold in the 3-d space. That is to say your “contour" has 2 dimensions
 of thickness and 1 dimension that only 1 pixel thick. If you have planar edges this can result in large areas that are solid contours. Please look at the results of “unexpected” contours in the xy-plane xz-plane _and_ yz_ plane to understand the geometry.</div>
<div class=""><br class="">
</div>
<div class="">Alternatively, if the requirement is to have each slice look like a 1-d contour you can run contour filter in the SliceBySliceImageFitler[1]. However, this will omit the edges that are between slices.</div>
<div class=""><br class="">
</div>
<div class="">HTH,</div>
<div class="">Brad</div>
<div class=""><br class="">
</div>
<div class="">[1] <a href="https://itk.org/Doxygen/html/classitk_1_1SliceBySliceImageFilter.html" class="">https://itk.org/Doxygen/html/classitk_1_1SliceBySliceImageFilter.html</a></div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Feb 7, 2017, at 8:33 AM, Abdelkhalek Bakkari <<a href="mailto:bakkari.abdelkhalek@hotmail.fr" class="">bakkari.abdelkhalek@hotmail.fr</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="auto" class="">
<div class="">I am sorry but i did not find the <span style="background-color: rgba(255, 255, 255, 0);" class="">
SetUsePixelSpacingOff. Could you explain to me the way of using it. Also, what actually does it mean to turn off the spacing between slices and slice pixel and how is it related to contour generation .</span></div>
<div class="">Kind regards,<br class="">
<br class="">
Sent from my iPhone</div>
<div class=""><br class="">
On 7 Feb 2017, at 13:46, Dženan Zukić <<a href="mailto:dzenanz@gmail.com" class="">dzenanz@gmail.com</a>> wrote:<br class="">
<br class="">
</div>
<blockquote type="cite" class="">
<div class="">
<div dir="auto" class="">Try SetUsePixelSpacingOff.</div>
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On Feb 7, 2017 06:30, "Abdelkhalek Bakkari" <<a href="mailto:bakkari.abdelkhalek@hotmail.fr" class="">bakkari.abdelkhalek@hotmail.fr</a>> wrote:<br type="attribution" class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="">
<div id="m_2094535964551032782divtagdefaultwrapper" style="font-size: 12pt; font-family: 'Times New Roman', Times, serif;" dir="ltr" class="">
<p class="">Dear ITK users,</p>
<p class=""><br class="">
</p>
<p class="">After using the BinaryFillHoleFilter for a 3D Dicom image (see attached), I adopted the <span class="">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 class=""><span class=""><br class="">
</span></p>
<p class=""><span class="">The fragment of my code is :</span></p>
<p class=""><span class=""><br class="">
</span></p>
<p class=""><span class="">------------------------------<wbr class="">------------------------</span></p>
<div class=""><span class=""></span><br class="webkit-block-placeholder">
</div>
<div class="">#include "itkImage.h"</div>
<div class="">#include "itkImageFileReader.h"</div>
<div class="">#include "itkImageFileWriter.h"</div>
<div class="">#include "<wbr class="">itkRescaleIntensityImageFilter<wbr class="">.h"</div>
<div class="">#include "itkCastImageFilter.h"</div>
<div class="">#include "<wbr class="">itkCannyEdgeDetectionImageFilt<wbr class="">er.h"</div>
<div class="">#include <itkBinaryContourImageFilter.<wbr class="">h></div>
<div class="">#include <vtkImageData.h></div>
<div class="">#include <vtkExtractVOI.h></div>
<div class="">#include <itkLabelToRGBImageFilter.h></div>
<div class="">#include <itkImageToVTKImageFilter.h></div>
<div class="">#include <itkVTKImageToImageFilter.h></div>
<div class="">#include <vtkSmartPointer.h></div>
<div class=""><br class="">
</div>
<div class="">int main(int argc, char **argv)</div>
<div class="">{</div>
<br class="">
<div class=""><br class="webkit-block-placeholder">
</div>
<div class=""><span class=""></span><br class="webkit-block-placeholder">
</div>
<div class="">       const unsigned int     Dimension = 3;</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>typedef unsigned char<span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap">
</span>InputPixelType;</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>typedef unsigned char  OutputPixelType;</div>
<div class=""><br class="">
</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>typedef itk::Image<InputPixelType, Dimension>  InputImageType;</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>typedef itk::Image<OutputPixelType, Dimension> OutputImageType;</div>
<div class=""><br class="">
</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>typedef itk::ImageFileReader< InputImageType > ReaderType;</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>ReaderType::Pointer reader = ReaderType::New();</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>reader->SetFileName("<wbr class="">BinaryFillHoleImage.mha");</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>reader->Update();</div>
<div class=""><br class="">
</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>//Slice by Slice Binary Contour</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>// Binary Contour Filter</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>typedef itk::BinaryContourImageFilter <InputImageType, InputImageType > binaryContourImageFilterType;</div>
<div class=""><br class="">
</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>binaryContourImageFilterType::<wbr class="">Pointer binaryContourFilter = binaryContourImageFilterType::<wbr class="">New ();</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>binaryContourFilter->SetInput(<wbr class="">reader->GetOutput());</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>binaryContourFilter-><wbr class="">SetFullyConnected(1); // true makes thicker contours</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>binaryContourFilter-><wbr class="">SetBackgroundValue(0);</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>binaryContourFilter-><wbr class="">SetForegroundValue(255); // the value of your binary mask</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>binaryContourFilter->Update();</div>
<div class=""><br class="">
</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>typedef itk::<wbr class="">RescaleIntensityImageFilter< InputImageType, InputImageType > RescaleType;</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>RescaleType::Pointer rescaler = RescaleType::New();</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>rescaler->SetInput( binaryContourFilter-><wbr class="">GetOutput() );</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>rescaler->SetOutputMinimum( 0 );</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>rescaler->SetOutputMaximum( 255 );</div>
<div class=""><br class="">
</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>typedef itk::CastImageFilter< InputImageType, OutputImageType > FilterType;</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>FilterType::Pointer filter = FilterType::New();</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>filter->SetInput( rescaler->GetOutput() );</div>
<div class=""><br class="">
</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>// Save the contour</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>{</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>typedef itk::ImageFileWriter<<wbr class="">OutputImageType> WriterType;</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>WriterType::Pointer writer = WriterType::New();</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>writer->SetFileName("<wbr class="">Cannybinarycontour.mha");</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>writer->SetInput(filter-><wbr class="">GetOutput());</div>
<div class=""><br class="">
</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>try{</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>writer->Update();</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>}</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>catch(itk::ExceptionObject &e)</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>{</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>std::cerr << e << std::endl;</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>}</div>
<div class=""><span class="m_2094535964551032782Apple-tab-span" style="white-space:pre-wrap"></span>}</div>
<div class=""><br class="">
</div>
<div class="">    return EXIT_SUCCESS;</div>
<div class="">}</div>
<br class="">
<div class=""><br class="webkit-block-placeholder">
</div>
<div class=""><br class="webkit-block-placeholder">
</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" class="">
------------------------------<wbr class="">------------------------</p>
<div class=""><br class="">
</div>
<div style="font-family: 'Times New Roman', Times, serif, 'Apple Color Emoji', 'Segoe UI Emoji', NotoColorEmoji, 'Segoe UI Symbol', 'Android Emoji', EmojiSymbols; font-size: 16px;" class="">
<br class="webkit-block-placeholder">
</div>
Thank you in advance.
<div class=""><br class="webkit-block-placeholder">
</div>
<p class=""><br class="">
</p>
<p class="">Best regards,</p>
<p class=""><br class="">
</p>
<div id="m_2094535964551032782Signature" class=""><font size="3" face="Garamond" class="">Abdelkhalek Bakkari</font>
<div class=""><span style="line-height:14px" class=""><font size="3" face="Garamond" class="">Ph.D candidate in Computer Science</font></span></div>
<div class=""><span style="line-height:20.82666778564453px;background-color:rgb(255,255,255)" class=""><font face="Garamond" size="3" class="">Institute of Applied Computer Science</font></span></div>
<div class=""><span style="line-height:18.399999618530273px" class=""><font face="Garamond" size="3" class="">Lodz University of Technology, Poland</font></span></div>
<div class=""><span style="line-height:18.399999618530273px" class=""><font face="Garamond" size="3" class=""><br class="">
</font></span></div>
<div class=""><br class="">
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
_____________________________________<br class="">
Powered by <a href="http://www.kitware.com" class="">www.kitware.com</a><br class="">
<br class="">
Visit other Kitware open-source projects at<br class="">
<a href="http://www.kitware.com/opensource/opensource.html" class="">http://www.kitware.com/opensource/opensource.html</a><br class="">
<br class="">
Kitware offers ITK Training Courses, for more information visit:<br class="">
http://www.kitware.com/products/protraining.php<br class="">
<br class="">
Please keep messages on-topic and check the ITK FAQ at:<br class="">
http://www.itk.org/Wiki/ITK_FAQ<br class="">
<br class="">
Follow this link to subscribe/unsubscribe:<br class="">
http://public.kitware.com/mailman/listinfo/insight-users<br class="">
_______________________________________________<br class="">
Community mailing list<br class="">
Community@itk.org<br class="">
http://public.kitware.com/mailman/listinfo/community<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>