[Insight-users] Mean Shift Blurring Filter

camille orny camille.orny at gmail.com
Fri Jul 31 13:15:57 EDT 2009


Hello,

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.

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.

Are there any problems with that filter ?

Regards,

typedef itk::Image< PixelType, 2> TInputImage;
typedef itk::Image< PixelType, 2> TOutputImage;
typedef itk::Image< unsigned char, 2> TOutputImage2;
typedef otb::ImageFileReader< TInputImage> ReaderType;
typedef itk::Statistics::ScalarImageToListAdaptor<TInputImage> SampleType;

typedef itk::RescaleIntensityImageFilter<TOutputImage,TOutputImage2>
RescalerType;
typedef otb::StreamingImageFileWriter<TOutputImage> WriterType;
typedef otb::StreamingImageFileWriter<TOutputImage2> WriterType2;
//typedef std::vector< int > ClusterLabelsType;
typedef itk::Statistics::SampleMeanShiftBlurringFilter<SampleType>
FilterType;

//typedef itk::FixedArray<int, 1> TVector;
//typedef itk::Statistics::ListSample < TVector > ListSampleType;

ReaderType::Pointer reader=ReaderType::New();
SampleType::Pointer sample=SampleType::New();
FilterType::Pointer filter=FilterType::New();
WriterType::Pointer writer=WriterType::New();
WriterType2::Pointer writer2=WriterType2::New();
//RescalerType::Pointer rescaler=RescalerType::New();

reader->SetFileName(argv[1]);
reader->Update();
TInputImage::Pointer inimage=reader->GetOutput();

sample->SetImage(inimage);

filter->SetInputSample(sample);
filter->Update();

TOutputImage::Pointer limage=TOutputImage::New();
limage->CopyInformation(inimage);
limage->SetRegions(limage->GetLargestPossibleRegion());
limage->Allocate();
limage->FillBuffer(0);


itk::ImageRegionIterator<TOutputImage>
lit(limage,limage->GetLargestPossibleRegion());
lit.GoToBegin();


ListSampleType::Iterator it=(filter->GetOutput())-> Begin();
int i=0;

std::cout<<"hello";

while(!lit.IsAtEnd() )

{
    std::cout<<"while";
  lit.Set((filter->GetOutput())->GetMeasurementVector(i)[0]);
  std::cout<<(filter->GetOutput())->GetMeasurementVectorSize();
  ++lit;
  ++it;
  ++i;
}

writer->SetInput(inimage);
writer->SetFileName(argv[2]);
writer->Update();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090731/0ad65f5e/attachment.htm>


More information about the Insight-users mailing list