// We set the file names for the reader and the writers:
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
reader->SetFileName(infname);
writer1->SetFileName(clusteredfname);
writer2->SetFileName(labeledfname);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We can now set the parameters for the filter. There are 3 main
// parameters: the spatial radius used for defining the neighborhood,
// the range radius used for defining the interval in the color space
// and the minimum size for the regions to be kept after clustering.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
filter->SetSpatialBandwidth(spatialRadius);
filter->SetRangeBandwidth(rangeRadius);
filter->SetMinRegionSize(minRegionSize);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Two another parameters can be set the maximum iteration number, which define maximum number of iteration until convergence.
// Algorithm iterative scheme will stop if convergence hasn't been reached after the maximum number of iterations.
// Threshold parameter defines mean-shift vector convergence value. Algorithm iterative scheme will stop if mean-shift vector is below this threshold or if iteration number reached maximum number of iterations.
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
filter->SetMaxIterationNumber(maxiter);
filter->SetThreshold(thres);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We can now plug the pipeline and run it.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
filter->SetInput(reader->GetOutput());
writer1->SetInput(filter->GetClusteredOutput());
writer2->SetInput(filter->GetLabelOutput());
writer1->Update();
writer2->Update();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
// Figure~\ref{fig:MeanShiftSegmentationFilter} shows the result of applying the mean shift