Skip to content
Snippets Groups Projects
Commit f5607625 authored by Jonathan Guinet's avatar Jonathan Guinet
Browse files

ENH: modesearch option name change.

parent f6621859
Branches
Tags
No related merge requests found
......@@ -411,7 +411,7 @@ private:
*
* MeanShifVector squared norm is compared with Threshold (set using Get/Set accessor) to define pixel convergence (1e-3 by default).
* MaxIterationNumber defines maximum iteration number for each pixel convergence (set using Get/Set accessor). Set to 4 by default.
* ModeSearchOptimization is a boolean value, to choose between optimized and non optimized algorithm. If set to true (by default), assign mode value to each pixel on a path covered in convergence steps.
* ModeSearch is a boolean value, to choose between optimized and non optimized algorithm. If set to true (by default), assign mode value to each pixel on a path covered in convergence steps.
*
* For more information on mean shift techniques, one might consider reading the following article:
*
......@@ -499,11 +499,12 @@ public:
itkGetConstReferenceMacro(Threshold, double);
itkSetMacro(Threshold, double);
/** Toggle mode search optimization, which is enabled by default.
/** Toggle mode search, which is enabled by default.
* When off, the output label image is not available
* Be careful, with this option, the result will slightly depend on thread number.
*/
itkSetMacro(ModeSearchOptimization, bool);
itkGetConstReferenceMacro(ModeSearchOptimization, bool);
itkSetMacro(ModeSearch, bool);
itkGetConstReferenceMacro(ModeSearch, bool);
/** Toggle bucket optimization, which is disabled by default.
*/
......@@ -609,8 +610,8 @@ private:
*/
typename ModeTableImageType::Pointer m_ModeTable;
/** Boolean to enable mode search optimization */
bool m_ModeSearchOptimization;
/** Boolean to enable mode search */
bool m_ModeSearch;
/** Boolean to enable bucket optimization */
bool m_BucketOptimization;
......
......@@ -42,7 +42,7 @@ MeanShiftSmoothingImageFilter<TInputImage, TOutputImage, TKernel, TOutputIterati
// , m_NumberOfComponentsPerPixel(...)
// , m_JointImage(0)
// , m_ModeTable(0)
, m_ModeSearchOptimization( true )
, m_ModeSearch( true )
, m_BucketOptimization( false )
{
this->SetNumberOfOutputs(4);
......@@ -316,13 +316,13 @@ MeanShiftSmoothingImageFilter<TInputImage, TOutputImage, TKernel, TOutputIterati
}
*/
//TODO don't create mode table iterator when ModeSearchOptimization is set to false
//TODO don't create mode table iterator when ModeSearch is set to false
m_ModeTable = ModeTableImageType::New();
m_ModeTable->SetRegions(inputPtr->GetRequestedRegion());
m_ModeTable->Allocate();
m_ModeTable->FillBuffer(0);
if (m_ModeSearchOptimization)
if (m_ModeSearch)
{
// Image to store the status at each pixel:
// 0 : no mode has been found yet
......@@ -610,7 +610,7 @@ MeanShiftSmoothingImageFilter<TInputImage, TOutputImage, TKernel, TOutputIterati
// Variables used by mode search optimization
// List of indices where the current pixel passes through
std::vector<InputIndexType> pointList;
if(m_ModeSearchOptimization) pointList.resize(m_MaxIterationNumber);
if(m_ModeSearch) pointList.resize(m_MaxIterationNumber);
// Number of times an already processed candidate pixel is encountered, resulting in no
// further computation (Used for statistics only)
unsigned int numBreaks = 0;
......@@ -624,7 +624,7 @@ MeanShiftSmoothingImageFilter<TInputImage, TOutputImage, TKernel, TOutputIterati
// if pixel has been already processed (by mode search optimization), skip
typename ModeTableImageType::InternalPixelType const& currentPixelMode = modeTableIt.Get();
if(m_ModeSearchOptimization && currentPixelMode == 1)
if(m_ModeSearch && currentPixelMode == 1)
{
numBreaks++;
continue;
......@@ -645,7 +645,7 @@ MeanShiftSmoothingImageFilter<TInputImage, TOutputImage, TKernel, TOutputIterati
while ((iteration < m_MaxIterationNumber) && (!hasConverged))
{
if (m_ModeSearchOptimization)
if (m_ModeSearch)
{
// Find index of the pixel closest to the current jointPixel (not normalized by bandwidth)
for (unsigned int comp = 0; comp < ImageDimension; comp++)
......@@ -697,7 +697,7 @@ MeanShiftSmoothingImageFilter<TInputImage, TOutputImage, TKernel, TOutputIterati
}
}
} // end if (m_ModeSearchOptimization)
} // end if (m_ModeSearch)
//Calculate meanShiftVector
if(m_BucketOptimization)
......@@ -740,7 +740,7 @@ MeanShiftSmoothingImageFilter<TInputImage, TOutputImage, TKernel, TOutputIterati
const typename OutputIterationImageType::PixelType iterationPixel = iteration;
iterationIt.Set(iterationPixel);
if (m_ModeSearchOptimization)
if (m_ModeSearch)
{
// Update the mode table now that the current pixel has been assigned
modeTableIt.Set(1); // m_ModeTable->SetPixel(currentIndex, 1);
......@@ -765,7 +765,7 @@ MeanShiftSmoothingImageFilter<TInputImage, TOutputImage, TKernel, TOutputIterati
labelOutput->SetPixel(pointList[i], label);
}
}
else // if ModeSearchOptimization is not set LabelOutput can't be generated
else // if ModeSearch is not set LabelOutput can't be generated
{
LabelType labelZero=0;
labelIt.Set(labelZero);
......@@ -788,7 +788,7 @@ MeanShiftSmoothingImageFilter<TInputImage, TOutputImage, TKernel, TOutputIterati
// Reassign mode labels
// Note: Labels are only computed when mode search optimization is enabled
if (m_ModeSearchOptimization)
if (m_ModeSearch)
{
// New labels will be consecutive. The following vector contains the new
// start label for each thread.
......
......@@ -27,7 +27,7 @@ int otbMeanShiftSmoothingImageFilter(int argc, char * argv[])
if (argc != 10 && argc != 11)
{
std::cerr << "Usage: " << argv[0] <<
" infname spatialfname spectralfname iterationfname labelfname spatialBandwidth rangeBandwidth threshold maxiterationnumber (useoptimization)"
" infname spatialfname spectralfname iterationfname labelfname spatialBandwidth rangeBandwidth threshold maxiterationnumber (usemodesearch)"
<< std::endl;
return EXIT_FAILURE;
}
......@@ -41,10 +41,10 @@ int otbMeanShiftSmoothingImageFilter(int argc, char * argv[])
const double rangeBandwidth = atof(argv[7]);
const double threshold = atof(argv[8]);
const unsigned int maxiterationnumber = atoi(argv[9]);
bool useoptimization = true;
bool usemodesearch = true;
if(argc==11)
{
useoptimization = atoi(argv[10])!=0;
usemodesearch = atoi(argv[10])!=0;
}
/* maxit - threshold */
......@@ -75,7 +75,7 @@ int otbMeanShiftSmoothingImageFilter(int argc, char * argv[])
filter->SetThreshold(threshold);
filter->SetMaxIterationNumber(maxiterationnumber);
filter->SetInput(reader->GetOutput());
filter->SetModeSearchOptimization(useoptimization);
filter->SetModeSearch(usemodesearch);
//filter->SetNumberOfThreads(1);
SpatialWriterType::Pointer writer1 = SpatialWriterType::New();
WriterType::Pointer writer2 = WriterType::New();
......@@ -89,7 +89,7 @@ int otbMeanShiftSmoothingImageFilter(int argc, char * argv[])
writer2->SetInput(filter->GetRangeOutput());
writer4->SetInput(filter->GetIterationOutput());
if (useoptimization) //mode label image is only available with mode search optimization
if (usemodesearch) //mode label image is only available with mode search optimization
{
LabelWriterType::Pointer writer5 = LabelWriterType::New();
writer5->SetFileName(labelfname);
......
......@@ -27,7 +27,7 @@ int otbMeanShiftSmoothingImageFilterThreading(int argc, char * argv[])
if (argc != 7)
{
std::cerr << "Usage: " << argv[0] <<
" inputFileName outputSingleThreadFileName outputMultiThreadFileName spatialBandwidth rangeBandwidth useOptimization"
" inputFileName outputSingleThreadFileName outputMultiThreadFileName spatialBandwidth rangeBandwidth useModeSearch"
<< std::endl;
return EXIT_FAILURE;
}
......@@ -37,7 +37,7 @@ int otbMeanShiftSmoothingImageFilterThreading(int argc, char * argv[])
const char * outputMultiThreadFileName = argv[3];
const double spatialBandwidth = atof(argv[4]);
const double rangeBandwidth = atof(argv[5]);
bool useOptimization = (atoi(argv[6])!=0);
bool useModeSearch = (atoi(argv[6])!=0);
const unsigned int Dimension = 2;
typedef float PixelType;
......@@ -58,13 +58,13 @@ int otbMeanShiftSmoothingImageFilterThreading(int argc, char * argv[])
filterSingle->SetSpatialBandwidth(spatialBandwidth);
filterSingle->SetRangeBandwidth(rangeBandwidth);
filterSingle->SetInput(reader->GetOutput());
filterSingle->SetModeSearchOptimization(useOptimization);
filterSingle->SetModeSearch(useModeSearch);
filterSingle->SetNumberOfThreads(1);
filterMulti->SetSpatialBandwidth(spatialBandwidth);
filterMulti->SetRangeBandwidth(rangeBandwidth);
filterMulti->SetInput(reader->GetOutput());
filterMulti->SetModeSearchOptimization(useOptimization);
filterMulti->SetModeSearch(useModeSearch);
WriterType::Pointer writerSingle = WriterType::New();
WriterType::Pointer writerMulti = WriterType::New();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment