1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
|
/*=========================================================================
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 otbGenericRoadExtractionFilter_h
#define otbGenericRoadExtractionFilter_h
#include "itkUnaryFunctorImageFilter.h"
#include "itkGradientRecursiveGaussianImageFilter.h"
#include "otbVectorImage.h"
#include "otbImageToPathListFilter.h"
#include "itkSqrtImageFilter.h"
#include "otbNeighborhoodScalarProductFilter.h"
#include "otbNonMaxRemovalByDirectionFilter.h"
#include "otbVectorizationPathListFilter.h"
#include "otbSimplifyPathListFilter.h"
#include "otbBreakAngularPathListFilter.h"
#include "otbRemoveTortuousPathListFilter.h"
#include "otbLinkPathListFilter.h"
#include "otbRemoveIsolatedByDirectionFilter.h"
#include "otbRemoveWrongDirectionFilter.h"
#include "otbLikelihoodPathListFilter.h"
namespace otb
{
/**
* \class GenericRoadExtractionFilter
* \brief This class performs the extraction of roads from an image.
*
* This composite filter implements a fast and robust road extraction
* for high resolution satellite images. The line
* detection is done using a Gaussian gradient with a scalar product to find
* the road directions. Finally, extracted roads are vectorized and
* processed to improve the results removing some occultations and false
* detections.
*
* The full method is detailed in E. Christophe and J. Inglada, "Robust Road
* Extraction for High Resolution Satellite Images," in IEEE International
* Conference on Image Processing, ICIP'07, 2007.
*
* This filter is fast, as the detection typically takes 3 seconds for a
* 1000 \f$ \times \f$ 1000 images with four spectral bands. Results can be
* used as an initialization for more complex algorithms.
*
* \sa itk::SqrtImageFilter
* \sa itk::GradientRecursiveGaussianImageFilter
* \sa NeighborhoodScalarProductFilter
* \sa RemoveIsolatedByDirectionFilter
* \sa RemoveWrongDirectionFilter
* \sa NonMaxRemovalByDirectionFilter
* \sa VectorizationPathListFilter
* \sa SimplifyPathListFilter
* \sa BreakAngularPathListFilter
* \sa RemoveTortuousPathListFilter
* \sa LinkPathListFilter
* \sa LikelihoodPathListFilter
*
* \ingroup OTBRoadExtraction
*/
template <class TInputImage, class TOutputPath>
class ITK_EXPORT GenericRoadExtractionFilter
: public ImageToPathListFilter<TInputImage, TOutputPath>
{
public:
/** Standard typedefs */
typedef GenericRoadExtractionFilter Self;
typedef ImageToPathListFilter<TInputImage, TOutputPath> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Creation through object factory macro */
itkNewMacro(Self);
/** Type macro */
itkTypeMacro(GenericRoadExtractionFilter, ImageToPathListFilter);
/** Template parameters typedefs */
typedef typename Superclass::InputImageType InputImageType;
typedef typename Superclass::OutputPathType OutputPathType;
typedef typename Superclass::OutputPathListType OutputPathListType;
typedef typename InputImageType::PixelType InputPixelType;
typedef double InternalPixelType;
typedef otb::VectorImage<InternalPixelType, InputImageType::ImageDimension> VectorImageType;
typedef otb::Image<InternalPixelType, InputImageType::ImageDimension> ModulusType;
typedef otb::Image<InternalPixelType, InputImageType::ImageDimension> DirectionType;
typedef itk::CovariantVector<InternalPixelType, InputImageType::ImageDimension>
VectorPixelType;
typedef otb::Image<VectorPixelType, InputImageType::ImageDimension> CovariantVectorImageType;
typedef itk::SqrtImageFilter<
InputImageType,
InputImageType> SquareRootImageFilterType;
typedef itk::GradientRecursiveGaussianImageFilter<
InputImageType,
CovariantVectorImageType> GradientFilterType;
typedef NeighborhoodScalarProductFilter<
CovariantVectorImageType,
ModulusType,
DirectionType> NeighborhoodScalarProductFilterType;
typedef RemoveIsolatedByDirectionFilter<
ModulusType,
DirectionType,
ModulusType> RemoveIsolatedByDirectionFilterType;
typedef RemoveWrongDirectionFilter<
ModulusType,
DirectionType,
ModulusType> RemoveWrongDirectionFilterType;
typedef NonMaxRemovalByDirectionFilter<
ModulusType,
DirectionType,
ModulusType> NonMaxRemovalByDirectionFilterType;
typedef VectorizationPathListFilter<
ModulusType,
DirectionType,
OutputPathType> VectorizationPathListFilterType;
typedef SimplifyPathListFilter<OutputPathType> SimplifyPathListFilterType;
typedef BreakAngularPathListFilter<OutputPathType> BreakAngularPathListFilterType;
typedef RemoveTortuousPathListFilter<OutputPathType> RemoveTortuousPathListFilterType;
typedef LinkPathListFilter<OutputPathType> LinkPathListFilterType;
typedef LikelihoodPathListFilter<OutputPathType, ModulusType> LikelihoodPathListFilterType;
/** Template parameters typedefs for internals filters */
typedef typename GradientFilterType::RealType SigmaType;
typedef typename VectorizationPathListFilterType::InputPixelType AmplitudeThresholdType;
// typedef typename SimplifyPathListFilterType::ToleranceType ToleranceType;
typedef double ToleranceType;
typedef typename BreakAngularPathListFilterType::MaxAngleType MaxAngleType;
// typedef typename RemoveTortuousPathListFilterType::MeanDistanceThresholdType MeanDistanceThresholdType;
typedef double MeanDistanceThresholdType;
typedef typename LinkPathListFilterType::RealType LinkRealType;
/** Get/Set the alpha value */
itkGetConstReferenceMacro(Alpha, double);
itkSetMacro(Alpha, double);
/** Get/Set the amplitude threshold to start following a path (use by the VectorizationPathListFilter)*/
itkSetMacro(AmplitudeThreshold, AmplitudeThresholdType);
itkGetMacro(AmplitudeThreshold, AmplitudeThresholdType);
/** Get/Set the tolerance for segment consistency (tolerance in terms of distance) (use by the SimplifyPathListFilter)*/
itkGetMacro(Tolerance, ToleranceType);
itkSetMacro(Tolerance, ToleranceType);
/** Get/Set the resolution */
itkGetMacro(Resolution, double);
itkSetMacro(Resolution, double);
/** Set/Get the max angle (use bye the BreakAngularPathListFilter)*/
itkSetMacro(MaxAngle, MaxAngleType);
itkGetConstMacro(MaxAngle, MaxAngleType);
/** Get/Set the tolerance for segment consistency (tolerance in terms of distance) (use by RemoveTortuousPathListFilter)*/
itkGetMacro(FirstMeanDistanceThreshold, MeanDistanceThresholdType);
itkSetMacro(FirstMeanDistanceThreshold, MeanDistanceThresholdType);
itkGetMacro(SecondMeanDistanceThreshold, MeanDistanceThresholdType);
itkSetMacro(SecondMeanDistanceThreshold, MeanDistanceThresholdType);
/** Get/Set the angular threshold (use by LinkPathFilter)*/
itkSetMacro(AngularThreshold, LinkRealType);
itkGetMacro(AngularThreshold, LinkRealType);
/** Get/Set the distance threshold (use by LinkPathFilter)*/
itkSetMacro(DistanceThreshold, LinkRealType);
itkGetMacro(DistanceThreshold, LinkRealType);
protected:
/** Constructor */
GenericRoadExtractionFilter();
/** Destructor */
~GenericRoadExtractionFilter() ITK_OVERRIDE {}
/** Prepare main computation method
* Note : this function isn't called
*/
void BeforeGenerateData(void);
/** Main computation method */
void GenerateData(void) ITK_OVERRIDE;
/** PrintSelf method */
void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
private:
GenericRoadExtractionFilter(const Self &); // purposely not implemented
void operator =(const Self&); // purposely not implemented
typename SquareRootImageFilterType::Pointer m_SquareRootImageFilter;
typename GradientFilterType::Pointer m_GradientFilter;
typename NeighborhoodScalarProductFilterType::Pointer m_NeighborhoodScalarProductFilter;
typename RemoveIsolatedByDirectionFilterType::Pointer m_RemoveIsolatedByDirectionFilter;
typename RemoveWrongDirectionFilterType::Pointer m_RemoveWrongDirectionFilter;
typename NonMaxRemovalByDirectionFilterType::Pointer m_NonMaxRemovalByDirectionFilter;
typename VectorizationPathListFilterType::Pointer m_VectorizationPathListFilter;
typename SimplifyPathListFilterType::Pointer m_FirstSimplifyPathListFilter;
typename SimplifyPathListFilterType::Pointer m_SecondSimplifyPathListFilter;
typename BreakAngularPathListFilterType::Pointer m_BreakAngularPathListFilter;
typename RemoveTortuousPathListFilterType::Pointer m_FirstRemoveTortuousPathListFilter;
typename RemoveTortuousPathListFilterType::Pointer m_SecondRemoveTortuousPathListFilter;
typename LinkPathListFilterType::Pointer m_LinkPathListFilter;
typename LikelihoodPathListFilterType::Pointer m_LikelihoodPathListFilter;
/** Amplitude threshold to start following a path (use by the VectorizationPathListFilter)*/
AmplitudeThresholdType m_AmplitudeThreshold;
/** Tolerance for segment consistency (tolerance in terms of distance) (use by the SimplifyPathListFilter)*/
ToleranceType m_Tolerance;
/** Max angle (use bye the BreakAngularPathListFilter)*/
MaxAngleType m_MaxAngle;
/** Tolerance for segment consistency (tolerance in terms of distance) (use by RemoveTortuousPathListFilter)*/
MeanDistanceThresholdType m_FirstMeanDistanceThreshold;
MeanDistanceThresholdType m_SecondMeanDistanceThreshold;
/** The angular threshold (use by LinkPathListFilter) */
LinkRealType m_AngularThreshold;
/** The distance threshold (use by LinkPathListFilter) */
double m_DistanceThreshold;
/** Alpha. Use to calculate the sigma value used by the GradientRecursiveGaussianImageFilter */
double m_Alpha;
/** Resolution of the image. Use to calculate the sigma value used by the GradientRecursiveGaussianImageFilter
and the m_DistanceThreshold value used by the LinkPathListFilter
This value is set bye the image's spacing.*/
double m_Resolution;
};
} // End namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbGenericRoadExtractionFilter.txx"
#endif
#endif
|