<p>Hello,</p>
<p>I am trying to use the itk::SampleMeanShiftBlurringFilter to get, for each pixel, the value of the mode the mean shift algorithm associates it to.</p>
<p>I have written the following code which is compiled without any error reports. Hower I get a &quot;segmentation error&quot; when I execute it. It seems the problem comes from the line  filter-&gt;SetInputSample(sample); when I progressively comment the code.</p>

<p>Are there any problems with that filter ?</p>
<p>Regards,</p>
<p>typedef itk::Image&lt; PixelType, 2&gt; TInputImage;<br>typedef itk::Image&lt; PixelType, 2&gt; TOutputImage;<br>typedef itk::Image&lt; unsigned char, 2&gt; TOutputImage2;<br>typedef otb::ImageFileReader&lt;<br>TInputImage&gt; ReaderType;<br>
typedef itk::Statistics::ScalarImageToListAdaptor&lt;TInputImage&gt; SampleType;</p>
<p><br>typedef itk::RescaleIntensityImageFilter&lt;TOutputImage,TOutputImage2&gt; RescalerType;<br>typedef otb::StreamingImageFileWriter&lt;TOutputImage&gt; WriterType;<br>typedef otb::StreamingImageFileWriter&lt;TOutputImage2&gt; WriterType2;</p>

<p>//typedef std::vector&lt; int &gt; ClusterLabelsType;</p>
<p>typedef itk::Statistics::SampleMeanShiftBlurringFilter&lt;SampleType&gt; FilterType;</p>
<p><br>//typedef itk::FixedArray&lt;int, 1&gt; TVector;</p>
<p>//typedef itk::Statistics::ListSample &lt; TVector &gt; ListSampleType;</p>
<p>ReaderType::Pointer reader=ReaderType::New();<br>SampleType::Pointer sample=SampleType::New();<br>FilterType::Pointer filter=FilterType::New();<br>WriterType::Pointer writer=WriterType::New();<br>WriterType2::Pointer writer2=WriterType2::New();<br>
//RescalerType::Pointer rescaler=RescalerType::New();</p>
<p>reader-&gt;SetFileName(argv[1]);<br>reader-&gt;Update();<br>TInputImage::Pointer inimage=reader-&gt;GetOutput();</p>
<p>sample-&gt;SetImage(inimage);</p>
<p>filter-&gt;SetInputSample(sample);<br>filter-&gt;Update();</p>
<p>TOutputImage::Pointer limage=TOutputImage::New();<br>limage-&gt;CopyInformation(inimage);<br>limage-&gt;SetRegions(limage-&gt;GetLargestPossibleRegion());<br>limage-&gt;Allocate();<br>limage-&gt;FillBuffer(0);</p>
<p><br>itk::ImageRegionIterator&lt;TOutputImage&gt; lit(limage,limage-&gt;GetLargestPossibleRegion());<br>lit.GoToBegin();<br> </p>
<p><br>ListSampleType::Iterator it=(filter-&gt;GetOutput())-&gt;<br>Begin();<br>int i=0;</p>
<p>std::cout&lt;&lt;&quot;hello&quot;;</p>
<p>while(!lit.IsAtEnd() )</p>
<p>{<br>    std::cout&lt;&lt;&quot;while&quot;;<br>  lit.Set((filter-&gt;GetOutput())-&gt;GetMeasurementVector(i)[0]);<br>  std::cout&lt;&lt;(filter-&gt;GetOutput())-&gt;GetMeasurementVectorSize();<br>  ++lit;<br>  ++it;<br>
  ++i;<br>}</p>
<p>writer-&gt;SetInput(inimage);</p>
<p>writer-&gt;SetFileName(argv[2]);<br>writer-&gt;Update();</p>