<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 "segmentation error" when I execute it. It seems the problem comes from the line filter->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< PixelType, 2> TInputImage;<br>typedef itk::Image< PixelType, 2> TOutputImage;<br>typedef itk::Image< unsigned char, 2> TOutputImage2;<br>typedef otb::ImageFileReader<<br>TInputImage> ReaderType;<br>
typedef itk::Statistics::ScalarImageToListAdaptor<TInputImage> SampleType;</p>
<p><br>typedef itk::RescaleIntensityImageFilter<TOutputImage,TOutputImage2> RescalerType;<br>typedef otb::StreamingImageFileWriter<TOutputImage> WriterType;<br>typedef otb::StreamingImageFileWriter<TOutputImage2> WriterType2;</p>
<p>//typedef std::vector< int > ClusterLabelsType;</p>
<p>typedef itk::Statistics::SampleMeanShiftBlurringFilter<SampleType> FilterType;</p>
<p><br>//typedef itk::FixedArray<int, 1> TVector;</p>
<p>//typedef itk::Statistics::ListSample < TVector > 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->SetFileName(argv[1]);<br>reader->Update();<br>TInputImage::Pointer inimage=reader->GetOutput();</p>
<p>sample->SetImage(inimage);</p>
<p>filter->SetInputSample(sample);<br>filter->Update();</p>
<p>TOutputImage::Pointer limage=TOutputImage::New();<br>limage->CopyInformation(inimage);<br>limage->SetRegions(limage->GetLargestPossibleRegion());<br>limage->Allocate();<br>limage->FillBuffer(0);</p>
<p><br>itk::ImageRegionIterator<TOutputImage> lit(limage,limage->GetLargestPossibleRegion());<br>lit.GoToBegin();<br> </p>
<p><br>ListSampleType::Iterator it=(filter->GetOutput())-><br>Begin();<br>int i=0;</p>
<p>std::cout<<"hello";</p>
<p>while(!lit.IsAtEnd() )</p>
<p>{<br> std::cout<<"while";<br> lit.Set((filter->GetOutput())->GetMeasurementVector(i)[0]);<br> std::cout<<(filter->GetOutput())->GetMeasurementVectorSize();<br> ++lit;<br> ++it;<br>
++i;<br>}</p>
<p>writer->SetInput(inimage);</p>
<p>writer->SetFileName(argv[2]);<br>writer->Update();</p>