// We set the file names for the reader and the writers:
// We set the file names for the reader and the writers:
reader->SetFileName(infname);
writer1->SetFileName(clusteredfname);
writer2->SetFileName(labeledfname);
// 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.
// 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.
filter->SetSpatialBandwidth(spatialRadius);
filter->SetRangeBandwidth(rangeRadius);
filter->SetMinRegionSize(minRegionSize);
// Two another parameters can be set : the maximum iteration number, which defines 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.
// Two another parameters can be set: the maximum iteration number, which
// defines 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.
filter->SetMaxIterationNumber(maxiter);
filter->SetThreshold(thres);
// We can now plug the pipeline and run it.
// We can now plug the pipeline and run it.
filter->SetInput(reader->GetOutput());
writer1->SetInput(filter->GetClusteredOutput());
...
...
@@ -132,19 +118,6 @@ int main(int argc, char* argv[])
writer1->Update();
writer2->Update();
// Figure~\ref{fig:MeanShiftSegmentationFilter} shows the result of applying the mean shift