Commit 4dcdac23 authored by Stéphane Albert's avatar Stéphane Albert

ENH: Added missing ImageKeywordList::operator!=()

parents 5525c4ad 9f4def73
......@@ -25,7 +25,7 @@
// Software Guide : BeginLatex
//
// This example shows the basic approach to perform object based analysis on a image.
// The input image is firstly segmented using the \doxygen{otb}{MeanShiftImageFilter}
// The input image is firstly segmented using the \doxygen{otb}{MeanShiftSegmentationFilter}
// Then each segmented region is converted to a Map of labeled objects.
// Afterwards the \doxygen{otb}{otbMultiChannelRAndNIRIndexImageFilter} computes
// radiometric attributes for each object. In this example the NDVI is computed.
......@@ -41,7 +41,7 @@
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbMeanShiftVectorImageFilter.h"
#include "otbMeanShiftSegmentationFilter.h"
#include "itkLabelImageToLabelMapFilter.h"
#include "otbShapeAttributesLabelMapFilter.h"
#include "otbBandsStatisticsAttributesLabelMapFilter.h"
......@@ -79,7 +79,7 @@ int main(int argc, char * argv[])
const unsigned int Dimension = 2;
// Labeled image type
typedef unsigned short LabelType;
typedef unsigned int LabelType;
typedef unsigned char MaskPixelType;
typedef double PixelType;
typedef otb::Image<LabelType, Dimension> LabeledImageType;
......@@ -137,13 +137,14 @@ int main(int argc, char * argv[])
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::MeanShiftVectorImageFilter
<VectorImageType, VectorImageType, LabeledImageType> FilterType;
typedef otb::MeanShiftSegmentationFilter
<VectorImageType, LabeledImageType, VectorImageType> FilterType;
FilterType::Pointer filter = FilterType::New();
filter->SetSpatialRadius(spatialRadius);
filter->SetRangeRadius(rangeRadius);
filter->SetMinimumRegionSize(minRegionSize);
filter->SetScale(scale);
filter->SetSpatialBandwidth(spatialRadius);
filter->SetRangeBandwidth(rangeRadius);
filter->SetMinRegionSize(minRegionSize);
filter->SetThreshold(0.1);
filter->SetMaxIterationNumber(100);
// Software Guide : EndCodeSnippet
// For non regression tests, set the number of threads to 1
......@@ -152,7 +153,7 @@ int main(int argc, char * argv[])
// Software Guide : BeginLatex
//
// The \doxygen{otb}{MeanShiftImageFilter} type is instantiated using the image
// The \doxygen{otb}{MeanShiftSegmentationFilter} type is instantiated using the image
// types.
//
// Software Guide : EndLatex
......@@ -164,13 +165,13 @@ int main(int argc, char * argv[])
// Software Guide : BeginLatex
//
// The \doxygen{itk}{LabelImageToLabelMapFilter} type is instantiated using the output
// of the \doxygen{otb}{MeanShiftImageFilter}. This filter produces a labeled image
// of the \doxygen{otb}{MeanShiftSegmentationFilter}. This filter produces a labeled image
// where each segmented region has a unique label.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
LabelMapFilterType::Pointer labelMapFilter = LabelMapFilterType::New();
labelMapFilter->SetInput(filter->GetLabeledClusteredOutput());
labelMapFilter->SetInput(filter->GetLabelOutput());
labelMapFilter->SetBackgroundValue(itk::NumericTraits<LabelType>::min());
ShapeLabelMapFilterType::Pointer shapeLabelMapFilter =
......
......@@ -25,7 +25,7 @@
// The following example illustrates how to segment very large images
// using the \doxygen{otb}{StreamingImageToOGRLayerSegmentationFilter}. This filter is
// templated over the segmentation filter that will be used to segment each tile
// of the input image. In this example we will use the \doxygen{otb}{MeanShiftVectorImageFilter}.
// of the input image. In this example we will use the \doxygen{otb}{MeanShiftSegmentationFilter}.
// The labeled output image of each tile is then vectorized (using a filter based on GDALPolygonize)
// and stored into a \doxygen{otb}{ogr}{Layer} within the \doxygen{otb}{ogr}{DataSource}
// set as input. Finally a fusion filter, \doxygen{otb}{OGRLayerStreamStitchingFilter}, is used to merge polygons
......@@ -39,7 +39,7 @@
// Software Guide : BeginCodeSnippet
#include "otbStreamingImageToOGRLayerSegmentationFilter.h"
#include "otbOGRLayerStreamStitchingFilter.h"
#include "otbMeanShiftVectorImageFilter.h"
#include "otbMeanShiftSegmentationFilter.h"
// Software Guide : EndCodeSnippet
#include "otbVectorImage.h"
......@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
// Software Guide : BeginCodeSnippet
//typedef otb::MeanShiftSmoothingImageFilter<ImageType, ImageType> MeanShiftImageFilterType;
typedef otb::MeanShiftVectorImageFilter <ImageType, ImageType, LabelImageType> SegmentationFilterType;
typedef otb::MeanShiftSegmentationFilter <ImageType, LabelImageType, ImageType> SegmentationFilterType;
typedef otb::StreamingImageToOGRLayerSegmentationFilter<ImageType, SegmentationFilterType> StreamingVectorizedSegmentationType;
// Software Guide : EndCodeSnippet
......@@ -174,15 +174,17 @@ int main(int argc, char *argv[])
// Software Guide : BeginLatex
//
// Now we set the parameters to the segmentation filter.The \doxygen{otb}{MeanShiftVectorImageFilter}
// required three parameters, the spatial radius, the range radius and the minimum object size.
// Now we set the parameters to the segmentation filter.The \doxygen{otb}{MeanShiftSegmentationFilter}
// has three main parameters, the spatial radius, the range radius and the minimum object size.
// We use the \code{GetSegmentationFilter()} method on the \doxygen{otb}{StreamingVectorizedSegmentation}
// to get a pointer to the segmentation filter.
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
filter->GetSegmentationFilter()->SetSpatialRadius(spatialRadius);
filter->GetSegmentationFilter()->SetRangeRadius(rangeRadius);
filter->GetSegmentationFilter()->SetMinimumRegionSize(minimumObjectSize);
filter->GetSegmentationFilter()->SetSpatialBandwidth(spatialRadius);
filter->GetSegmentationFilter()->SetRangeBandwidth(rangeRadius);
filter->GetSegmentationFilter()->SetMinRegionSize(minimumObjectSize);
filter->GetSegmentationFilter()->SetThreshold(0.1);
filter->GetSegmentationFilter()->SetMaxIterationNumber(100);
// Software Guide : EndCodeSnippet
......
......@@ -28,9 +28,6 @@
#include "itkGradientMagnitudeImageFilter.h"
#include "otbWatershedSegmentationFilter.h"
#include "otbMorphologicalProfilesSegmentationFilter.h"
#ifdef OTB_USE_EDISON
#include "otbMeanShiftVectorImageFilter.h"
#endif
// Large scale vectorization framework
#include "otbStreamingImageToOGRLayerSegmentationFilter.h"
......@@ -61,13 +58,6 @@ public:
typedef UInt32ImageType MaskImageType;
// Segmentation filters typedefs
#ifdef OTB_USE_EDISON
// Edison mean-shift
typedef otb::MeanShiftVectorImageFilter
<FloatVectorImageType,
FloatVectorImageType,
LabelImageType> EdisonSegmentationFilterType;
#endif
// Home made mean-shift
typedef otb::MeanShiftSegmentationFilter
......@@ -110,12 +100,6 @@ public:
<FloatVectorImageType, MaskImageType> MaskMuParserFilterType;
// Vectorize filters
#ifdef OTB_USE_EDISON
// Edison mean-shift
typedef otb::StreamingImageToOGRLayerSegmentationFilter
<FloatVectorImageType,
EdisonSegmentationFilterType> EdisontreamingVectorizedSegmentationOGRType;
#endif
// Home made mean-shift
typedef otb::StreamingImageToOGRLayerSegmentationFilter
......@@ -212,27 +196,6 @@ private:
SetDefaultParameterInt("filter.meanshift.maxiter", 100);
SetMinimumParameterIntValue("filter.meanshift.maxiter", 1);
#ifdef OTB_USE_EDISON
AddChoice("filter.edison", "Edison mean-shift");
SetParameterDescription("filter.edison",
"Edison implementation of mean-shift algorithm, by its authors.");
// EDISON Meanshift Parameters
AddParameter(ParameterType_Int, "filter.edison.spatialr", "Spatial radius");
SetParameterDescription("filter.edison.spatialr", "Spatial radius defining neighborhood.");
AddParameter(ParameterType_Float, "filter.edison.ranger", "Range radius");
SetParameterDescription("filter.edison.ranger", "Range radius defining the radius (expressed in radiometry unit) in the multi-spectral space.");
AddParameter(ParameterType_Int, "filter.edison.minsize", "Minimum region size");
SetParameterDescription("filter.edison.minsize", "Minimum size of a region in segmentation. Smaller clusters will be merged to the neighboring cluster with the closest radiometry.");
AddParameter(ParameterType_Float, "filter.edison.scale", "Scale factor");
SetParameterDescription("filter.edison.scale", "Scaling of the image before processing. This is useful for images with narrow decimal ranges (like [0,1] for instance). ");
SetDefaultParameterInt("filter.edison.spatialr", 5);
SetDefaultParameterFloat("filter.edison.ranger", 15.0);
SetDefaultParameterInt("filter.edison.minsize", 100);
SetMinimumParameterIntValue("filter.edison.minsize", 0);
SetDefaultParameterFloat("filter.edison.scale", 1.);
#endif
//Connected component segmentation parameters
AddChoice("filter.cc", "Connected components");
SetParameterDescription("filter.cc", "Simple pixel-based connected-components algorithm with a user-defined connection condition.");
......@@ -600,34 +563,6 @@ private:
"in"),
layer, 0);
}
#ifdef OTB_USE_EDISON
else
if (segType == "edison")
{
otbAppLogINFO(<<"Use Edison Mean-shift segmentation."<<std::endl);
//segmentation parameters
const unsigned int spatialRadius = static_cast<unsigned int> (this->GetParameterInt("filter.edison.spatialr"));
const float rangeRadius = static_cast<float> (this->GetParameterFloat("filter.edison.ranger"));
const unsigned int
minimumObjectSize = static_cast<unsigned int> (this->GetParameterInt("filter.edison.minsize"));
const float scale = this->GetParameterFloat("filter.edison.scale");
EdisontreamingVectorizedSegmentationOGRType::Pointer
edisonVectorizationFilter = EdisontreamingVectorizedSegmentationOGRType::New();
edisonVectorizationFilter->GetSegmentationFilter()->SetSpatialRadius(spatialRadius);
edisonVectorizationFilter->GetSegmentationFilter()->SetRangeRadius(rangeRadius);
edisonVectorizationFilter->GetSegmentationFilter()->SetMinimumRegionSize(minimumObjectSize);
edisonVectorizationFilter->GetSegmentationFilter()->SetScale(scale);
streamSize = GenericApplySegmentation<FloatVectorImageType, EdisonSegmentationFilterType> (
edisonVectorizationFilter,
this->GetParameterFloatVectorImage(
"in"),
layer, 2);
}
#endif
else
if (segType == "meanshift")
{
......
......@@ -24,9 +24,6 @@ otb_module(OTBAppSegmentation
OTBLabelMap
OTBProjection
OPTIONAL_DEPENDS
OTBEdisonMeanShift
TEST_DEPENDS
OTBTestKernel
OTBCommandLine
......
......@@ -24,9 +24,6 @@ set(vector_ref_path ${BASELINE_FILES})
set(raster_ref_path ${BASELINE})
set(fitlerList "Meanshift" "CC" "Watershed")
if(OTB_USE_EDISON)
list(APPEND fitlerList "Edison")
endif()
# Loop on modes
foreach(mode "Raster" "Vector")
......
......@@ -444,7 +444,7 @@ private:
* D. Comaniciu, P. Meer, "Mean Shift Analysis and Applications," iccv, p. 1197, Seventh International Conference
* on Computer Vision (ICCV'99) - Volume 2, 1999
*
* \sa MeanShiftImageFilter
* \sa MeanShiftSegmentationFilter
*
* \ingroup ImageSegmentation
* \ingroup ImageEnhancement
......
project(OTBEdisonMeanShift)
otb_module_impl()
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbMeanShiftImageFilter_h
#define __otbMeanShiftImageFilter_h
#include "vcl_deprecated_header.h"
#include "itkImageToImageFilter.h"
#include "itkVariableLengthVector.h"
#include "otbImage.h"
#include "otbObjectList.h"
#include "otbPolygon.h"
#include "otbLabeledOutputAccessor.h"
namespace otb
{
namespace MeanShift
{
/** \class ScalarBufferConverter
* \brief Small utilities class used for buffer conversion with EDISON standard.
* This class handles buffer conversion when pixel type is scalar.
* \deprecated
*
*
* \ingroup OTBEdisonMeanShift
**/
class ScalarBufferConverter
{
public:
/**
* Fill the pixel with the float array values at index, using nbComp values scaled by scale.
*/
template <class TPixel>
static inline void
FloatArrayToPixel(const float * data, unsigned int index, TPixel& pixel,
const unsigned int /*nbComp*/, double scale)
{
pixel = static_cast<TPixel>(scale * data[index]);
}
/**
* Fill the float array data with the pixel values at index, using nbComp values scaled by scale.
*/
template <class TPixel>
static inline void
PixelToFloatArray(float * data, unsigned int index, const TPixel& pixel, double scale)
{
data[index] = static_cast<float>(scale * pixel);
}
};
}
/** \class MeanShiftImageFilter
*
*
* Mean shift is a data clustering algorithm often used in image processing and segmentation.
* For a given pixel, the mean shift will build a set of neighboring pixels within a given spatial
* radius (can be set using SetSpatialRadius()) and a color range (can be set using SetRangeRadius()).
* The spatial and color center of this set is then computed and the algorithm iterates with this new spatial
* and color center.
*
* Mean shift can be used for edge-preserving smoothing, or for clustering. The GetOutput() method will allow
* you to get the smoothed image, whereas the
* GetClusteredOutput() methods returns the clustered output. The GetLabeledClusteredOutput() returns
* a labeled clustered image, and the GetClusterBoundariesOutput()
* an image of the cluster boundaries.
*
* The MinimumRegionSize parameter allows you to prune small clustered regions.
*
* This filter uses the Edison mean shift algorithm implementation. Please note that data whose precision
* is more than float are casted to float before processing.
*
* The Scale parameter allows you to stretch the data dynamic
*
* For more information on mean shift techniques, one might consider reading the following article:
*
* D. Comaniciu, P. Meer, "Mean Shift: A Robust Approach Toward Feature Space Analysis," IEEE Transactions on
* Pattern Analysis and Machine Intelligence, vol. 24, no. 5, pp. 603-619, May, 2002
* D. Comaniciu, P. Meer, "Robust analysis of feature spaces: color image segmentation," cvpr, p. 750, 1997
* IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR'97), 1997
* D. Comaniciu, P. Meer, "Mean Shift Analysis and Applications," iccv, p. 1197, Seventh International Conference
* on Computer Vision (ICCV'99) - Volume 2, 1999
*
* \deprecated use MeanShiftSegmentationFilter instead
*
* \sa MeanShiftSmootingImageFilter, MeanShiftSegmentationFilter
*
* \ingroup ImageEnhancement
*
* \ingroup OTBEdisonMeanShift
*/
template <class TInputImage, class TOutputImage,
class TLabeledOutput = otb::Image<unsigned short, 2>,
class TBufferConverter = MeanShift::ScalarBufferConverter>
class ITK_EXPORT MeanShiftImageFilter
: public itk::ImageToImageFilter<TInputImage, TOutputImage>
{
public:
/** Standard class typedef */
typedef MeanShiftImageFilter Self;
typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Type macro */
itkTypeMacro(MeanShiftImageFilter, ImageToImageFilter);
itkNewMacro(Self);
/** Template parameters typedefs */
typedef TInputImage InputImageType;
typedef typename InputImageType::Pointer InputImagePointerType;
typedef typename InputImageType::PixelType InputPixelType;
typedef typename InputImageType::PointType PointType;
typedef TOutputImage OutputImageType;
typedef typename OutputImageType::Pointer OutputImagePointerType;
typedef typename OutputImageType::PixelType OutputPixelType;
typedef typename OutputImageType::RegionType RegionType;
typedef TLabeledOutput LabeledOutputType;
typedef typename LabeledOutputType::Pointer LabeledOutputPointerType;
typedef typename LabeledOutputType::PixelType LabelType;
/** Typedefs for vectorized output */
typedef otb::Polygon<InputPixelType> PolygonType;
typedef typename PolygonType::Pointer PolygonPointerType;
typedef otb::ObjectList<PolygonType> PolygonListType;
typedef typename PolygonListType::Pointer PolygonListPointerType;
/** Typedef for mean-shift modes map */
typedef std::map<LabelType, InputPixelType> ModeMapType;
/** Setters / Getters */
itkSetMacro(SpatialRadius, unsigned int);
itkGetMacro(SpatialRadius, unsigned int);
itkSetMacro(RangeRadius, double);
itkGetMacro(RangeRadius, double);
itkSetMacro(MinimumRegionSize, unsigned int);
itkGetMacro(MinimumRegionSize, unsigned int);
itkSetMacro(Scale, double);
itkGetMacro(Scale, double);
/** Return the const clustered image output */
const OutputImageType * GetClusteredOutput() const;
/** Return the clustered image output */
OutputImageType * GetClusteredOutput();
/** Return the const labeled clustered image output */
const LabeledOutputType * GetLabeledClusteredOutput() const;
/** Return the labeled clustered image output */
LabeledOutputType * GetLabeledClusteredOutput();
/** Return the const cluster boundaries image output */
const LabeledOutputType * GetClusterBoundariesOutput() const;
/** Return the cluster boundaries image output */
LabeledOutputType * GetClusterBoundariesOutput();
/** Return the mean-shift mode by label */
const ModeMapType& GetModes()
{
return m_Modes;
}
protected:
virtual void EnlargeOutputRequestedRegion( itk::DataObject *output );
virtual void GenerateData();
/** Allocate the outputs (need to be reimplemented since outputs have differents type) */
virtual void AllocateOutputs();
/** If modified, we have to reset the list of modes */
virtual void Modified() const
{
Superclass::Modified();
m_Modes.clear();
}
/** Constructor */
MeanShiftImageFilter();
/** destructor */
virtual ~MeanShiftImageFilter() {}
/**PrintSelf method */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
MeanShiftImageFilter(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
/** Spatial radius for mean shift convergence */
unsigned int m_SpatialRadius;
/** Range radius for mean shift convergence */
double m_RangeRadius;
/** Minimum region size in pixels for clustering */
unsigned int m_MinimumRegionSize;
/** Data scale (used to stretch data range) */
double m_Scale;
/** A map of the different modes by segmented regions */
mutable ModeMapType m_Modes;
};
/**
* \class LabeledOutputAccessor
* \brief Specialized class to get the index of the labeled output image in mean shift filter.
*
* \ingroup OTBEdisonMeanShift
*/
template <class TInputImage, class TOutputImage, class TLabeledImage, class TBufferConverter>
class LabeledOutputAccessor<MeanShiftImageFilter<TInputImage, TOutputImage, TLabeledImage, TBufferConverter> >
{
public:
typedef typename MeanShiftImageFilter<TInputImage, TOutputImage, TLabeledImage, TBufferConverter>::LabeledOutputType LabelImageType;
itkStaticConstMacro(LabeledOutputIndex, unsigned int, 2);
};
} // end namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbMeanShiftImageFilter.txx"
#endif
#endif
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbMeanShiftVectorImageFilter_h
#define __otbMeanShiftVectorImageFilter_h
#include "vcl_deprecated_header.h"
#include "otbMeanShiftImageFilter.h"
namespace otb
{
namespace MeanShift
{
/** \class ScalarBufferConverter
* \brief Small utilities class used for buffer conversion with EDISON standard.
* This class handles buffer conversion when pixel type is scalar.
* \deprecated
*
* \ingroup OTBEdisonMeanShift
**/
class VectorBufferConverter
{
public:
/**
* Fill the pixel with the float array values at index, using nbComp values scaled by scale.
*/
template <class TPixel> static inline void FloatArrayToPixel(const float * data,
unsigned int index,
TPixel& pixel,
const unsigned int nbComp,
double scale)
{
pixel.SetSize(nbComp);
for (unsigned int i = 0; i < pixel.Size(); ++i)
{
pixel[i] = static_cast<typename TPixel::ValueType> (scale * data[index + i]);
}
}
/**
* Fill the float array data with the pixel values at index, using nbComp values scaled by scale.
*/
template <class TPixel> static inline void PixelToFloatArray(float * data,
unsigned int index,
const TPixel& pixel,
double scale)
{
for (unsigned int i = 0; i < pixel.Size(); ++i)
{
data[index + i] = static_cast<float>(scale * pixel[i]);
}
}
};
}
/** \class MeanShiftVectorImageFilter
*
* This is the implementation of the mean shift clustering and edge-preserving smoothing filter adapted to
* otb::VectorImage or itk::VectorImage. For the full documentation, please refer to the
* base class otb::MeanShiftImageFilter.
*
* \deprecated use MeanShiftSegmentationFilter instead
*
* \sa MeanShiftSmootingImageFilter, MeanShiftSegmentationFilter
*
* \ingroup ImageEnhancement
*
* \ingroup OTBEdisonMeanShift
*/
template <class TInputImage, class TOutputImage, class TLabeledOutput = otb::Image<unsigned short, 2> >
class MeanShiftVectorImageFilter
: public MeanShiftImageFilter<TInputImage, TOutputImage, TLabeledOutput, MeanShift::VectorBufferConverter>
{
public:
/** Standard class typedef */
typedef MeanShiftVectorImageFilter Self;
typedef MeanShiftImageFilter<TInputImage, TOutputImage, TLabeledOutput,
MeanShift::VectorBufferConverter> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Type macro */
itkTypeMacro(MeanShiftVectorImageFilter, MeanShiftImageFilter);
itkNewMacro(Self);
protected:
/** Constructor */
MeanShiftVectorImageFilter() {}
/** destructor */
virtual ~MeanShiftVectorImageFilter() {}
/**PrintSelf method */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
private:
MeanShiftVectorImageFilter(const Self&); //purposely not implemented
void operator =(const Self&); //purposely not implemented
};
/**
* \class LabeledOutputAccessor
* \brief Specialized class to get the index of the labeled output image in mean shift vector image filter.
*
* \ingroup OTBEdisonMeanShift
*/
template <class TInputImage, class TOutputImage, class TLabeledImage>
class LabeledOutputAccessor<MeanShiftVectorImageFilter<TInputImage, TOutputImage, TLabeledImage> >
{
public:
typedef typename MeanShiftVectorImageFilter<TInputImage, TOutputImage, TLabeledImage>::LabeledOutputType LabelImageType;
itkStaticConstMacro(LabeledOutputIndex, unsigned int, 2);
};
} // end namespace otb
#endif
set(DOCUMENTATION "This module implements the mean shift segmentation algorithm
(EDISON library).")
otb_module(OTBEdisonMeanShift
DEPENDS
OTBVectorDataBase
OTBEdison
OTBITK
OTBImageBase
OTBCommon
OTBLabelling
OTBObjectList
TEST_DEPENDS
OTBTestKernel
OTBImageIO
OTBImageManipulation
DESCRIPTION
"${DOCUMENTATION}"
)
#include "otbImage.h"
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbMeanShiftVectorImageFilter.h"
//Code adapted from submission from Christophe Simler
// http://bugs.orfeo-toolbox.org/view.php?id=41
int main(int argc, char *argv[])
{
if (argc < 9)
{
std::cout <<
"Usage : inputImage rangeRadius spatialRadius minRegionSize outfilenamefiltered outfilenamesegmented outfilenamelabeled outfilenameboundary"
<< std::endl;
return EXIT_FAILURE;
}
char * filename = argv[1];
int rangeRadius = atoi(argv[2]);
int spatialRadius = atoi(argv[3]);
int minRegionSize = atoi(argv[4]);
char * outfilenamefiltered = argv[5];
char * outfilenamesegmented = argv[6];
char * outfilenamelabeled = argv[7];
char * outfilenameboundary = argv[8];
typedef otb::VectorImage<unsigned char, 2> ImageType; // image d'entree, image filtree et image segmente
typedef otb::Image<int, 2> TLabeledOutput; // image labelisee, image des contours (de l'image labellisee)
// lecture de l'image d'entree a partir d'un fichier
typedef otb::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(filename);