Commit ec7e3e9d authored by Emmanuel Christophe's avatar Emmanuel Christophe

MRG

parents 36e0e59e 8fbfa016
......@@ -122,9 +122,9 @@ ConvolutionImageFilter< TInputImage, TOutputImage, TBoundaryCondition>
// Process each of the boundary faces. These are N-d regions which border
// the edge of the buffer.
for (fit=faceList.begin(); fit != faceList.end(); ++fit)
{
{
bit = itk::ConstNeighborhoodIterator<InputImageType>(m_Radius,
input, *fit);
input, *fit);
it = itk::ImageRegionIterator<OutputImageType>(output, *fit);
bit.OverrideBoundaryCondition(&nbc);
......@@ -132,31 +132,30 @@ ConvolutionImageFilter< TInputImage, TOutputImage, TBoundaryCondition>
unsigned int neighborhoodSize = bit.Size();
while ( ! bit.IsAtEnd() )
{
sum = itk::NumericTraits<InputRealType>::Zero;
norm = itk::NumericTraits<InputRealType>::Zero;
for (i = 0; i < neighborhoodSize; ++i)
{
sum = itk::NumericTraits<InputRealType>::Zero;
norm = itk::NumericTraits<InputRealType>::Zero;
for (i = 0; i < neighborhoodSize; ++i)
{
sum += static_cast<InputRealType>( bit.GetPixel(i)*m_Filter(i) );
norm += static_cast<InputRealType>( m_Filter(i) );
}
// get the mean value
if (m_NormalizeFilter)
{
it.Set( static_cast<OutputPixelType>(sum / double(norm)) );
}
else
{
it.Set( static_cast<OutputPixelType>(sum));
}
sum += static_cast<InputRealType>( bit.GetPixel(i)*m_Filter(i) );
norm += static_cast<InputRealType>( m_Filter(i) );
}
++bit;
++it;
progress.CompletedPixel();
// get the mean value
if (m_NormalizeFilter)
{
it.Set( static_cast<OutputPixelType>(sum / double(norm)) );
}
else
{
it.Set( static_cast<OutputPixelType>(sum));
}
++bit;
++it;
progress.CompletedPixel();
}
}
}
/**
......
......@@ -74,6 +74,11 @@ namespace otb
/** Set upper threshold */
itkSetMacro(UpperThreshold, InputPixelType);
/** Get Object count*/
// only set after completion
// itkGetConstReferenceMacro(ObjectCount, unsigned long);
itkGetMacro(ObjectCount, unsigned long);
/** Internal */
typedef otb::ThresholdImageToPointSetFilter<InputImageType, PointSetType> ThresholdFilterType;
typedef typename ThresholdFilterType::Pointer ThresholdFilterPointerType;
......@@ -81,7 +86,7 @@ namespace otb
typedef otb::MultiplyByScalarImageFilter<InputImageType, OutputImageType> MultiplyFilterType;
typedef typename MultiplyFilterType::Pointer MultiplyFilterPointerType;
typedef itk::AddImageFilter<InputImageType, InputImageType, OutputImageType> AddImageFilterType;
typedef itk::AddImageFilter<OutputImageType, OutputImageType, OutputImageType> AddImageFilterType;
typedef typename AddImageFilterType::Pointer AddImageFilterPointerType;
protected:
......@@ -113,10 +118,15 @@ namespace otb
/** Threshold point set filter */
ThresholdFilterPointerType m_ThresholdPointSetFilter;
/** Object counting */
unsigned long m_ObjectCount;
private:
LabelizeImageFilterBase(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
}; // end class LabelizeImageFilterBase
} // end namespace otb
......
......@@ -59,6 +59,7 @@ namespace otb
m_ThresholdPointSetFilter->SetUpperThreshold( m_UpperThreshold );
m_ThresholdPointSetFilter->Update();
m_PointSet = m_ThresholdPointSetFilter->GetOutput();
m_ObjectCount=0;
// Iterate Point set
typedef typename PointSetType::PointsContainer ContainerType;
......@@ -76,7 +77,7 @@ namespace otb
index[0] = static_cast <int> (pCoordinate[0]);
index[1] = static_cast <int> (pCoordinate[1]);
if (outputImage->GetPixel(index) ==
itk::NumericTraits<InputPixelType>::ZeroValue() )
itk::NumericTraits<OutputPixelType>::ZeroValue() )
{
this->RegionGrowing(index);
......@@ -85,12 +86,12 @@ namespace otb
addImage->SetInput2(m_RegionGrowingFilter->GetOutput());
addImage->Update();
outputImage = addImage->GetOutput();
++m_ObjectCount;
}
++itList;
}
this->GraftOutput(outputImage);
}
/** PrintSelf Method
......@@ -105,7 +106,7 @@ namespace otb
os << indent << "Seeds lower threshold: " << m_LowerThreshold << std::endl;
os << indent << "Seeds upper threshold: " << m_UpperThreshold << std::endl;
os << indent << "ObjectCount: " << m_ObjectCount << std::endl;
os << indent << m_RegionGrowingFilter << std::endl;
}
} // end namespace otb
......@@ -81,11 +81,18 @@ namespace otb
/** Get radius */
const InputSizeType& GetRadius() const
{ return this->m_RegionGrowingFilter->GetRadius(); }
{
return this->m_RegionGrowingFilter->GetRadius();
}
/** Set radius */
void SetRadius( const InputSizeType radius )
{ this->m_RegionGrowingFilter->SetRadius(radius); }
{
this->m_RegionGrowingFilter->SetRadius(radius);
this->Modified();
}
protected:
LabelizeNeighborhoodConnectedImageFilter();
......@@ -108,6 +115,7 @@ namespace otb
/** Intial replace value*/
OutputPixelType m_ReplaceValue;
}; // end class LabelizeconnectedThresholdImageFilter
} // end namespace otb
......
......@@ -88,6 +88,10 @@ public:
itkSetMacro(UseInternalPathValue,bool);
itkBooleanMacro(UseInternalPathValue);
itkGetMacro(AddValue,bool);
itkSetMacro(AddValue,bool);
itkBooleanMacro(AddValue);
itkSetMacro(PathValue,OutputImagePixelType);
itkGetMacro(PathValue,OutputImagePixelType);
......@@ -116,6 +120,8 @@ private:
OutputImagePixelType m_PathValue;
/** If set to true, the algorithm try to use path internal metadatadictionnary value */
bool m_UseInternalPathValue;
bool m_AddValue;
};
} // end namespace otb
......
......@@ -39,6 +39,7 @@ DrawPathListFilter<TInputImage,TInputPath,TOutputImage>
this->SetNumberOfRequiredOutputs(1);
m_PathValue = static_cast<OutputImagePixelType>(255);
m_UseInternalPathValue = false;
m_AddValue = false;
}
......@@ -93,7 +94,6 @@ DrawPathListFilter<TInputImage,TInputPath,TOutputImage>
}
// Then we use otb::PolyLineImageIterator to draw polylines
for(PathListIteratorType plIt = pathListPtr->Begin(); plIt!=pathListPtr->End();++plIt)
{
OutputImagePixelType value;
......@@ -106,10 +106,16 @@ DrawPathListFilter<TInputImage,TInputPath,TOutputImage>
value = static_cast<OutputImagePixelType>(m_PathValue);
}
PolyLineIteratorType imageIt(outputPtr,plIt.Get());
for(imageIt.GoToBegin();!imageIt.IsAtEnd();++imageIt)
{
imageIt.Set(value);
if (m_AddValue)
{
imageIt.Set(imageIt.Get()+1);
}
else
{
imageIt.Set(value);
}
}
}
}
......
......@@ -113,6 +113,17 @@ namespace otb
::GenerateData()
{
//Check if size is correct
typename InternalImageType::SizeType sizePan;
typename InternalVectorImageType::SizeType sizeXs;
sizePan = this->GetPanInput()->GetLargestPossibleRegion().GetSize();
sizeXs = this->GetXsInput()->GetLargestPossibleRegion().GetSize();
if ((sizePan[0] != sizeXs[0]) || (sizePan[1] != sizeXs[1]))
{
itkExceptionMacro(<<"SimpleRcsPanSharpeningFusionImageFilter: Wrong Pan/Xs size");
}
//Process the fusion
m_ConvolutionFilter->SetInput( this->GetPanInput() );
m_ConvolutionFilter->SetRadius( this->m_Radius);
m_ConvolutionFilter->SetFilter( this->m_Filter);
......
......@@ -111,6 +111,10 @@ namespace otb
SpacingType m_OutputSpacing;
SizeType m_OutputSize;
PixelType m_DefaultUnknownValue;
private:
DEMToImageGenerator(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
};
} // namespace otb
......
......@@ -95,15 +95,12 @@ namespace otb
// Walk the output image, evaluating the height at each pixel
IndexType currentindex;
PointType phyPoint;
PointType phyPointTemp;
double height;
for (outIt.GoToBegin(); !outIt.IsAtEnd(); ++outIt)
{
currentindex=outIt.GetIndex();
DEMImage->TransformIndexToPhysicalPoint(currentindex, phyPointTemp);
phyPoint[0] = phyPointTemp[0];
phyPoint[1] = phyPointTemp[1];
DEMImage->TransformIndexToPhysicalPoint(currentindex, phyPoint);
otbMsgDevMacro(<< "PhyPoint : (" << phyPoint[0] << "," << phyPoint[1] << ")") ;
......
/*=========================================================================
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 __otbDEMToOrthoImageGenerator_h
#define __otbDEMToOrthoImageGenerator_h
#include "itkIndent.h"
#include "otbDEMToImageGenerator.h"
#include "otbImage.h"
#include <iostream>
#include <stdio.h>
//#include "elevation/ossimElevManager.h"
#include "otbDEMHandler.h"
#include "base/ossimFilename.h"
#include "itkImageRegionIteratorWithIndex.h"
#include "itkIndent.h"
namespace otb
{
/** \class DEMToOrthoImageGenerator
*
* \brief Class for Reading a DEM data
*
* This class is based on ossimElevManager. It takes in input the UL and LR map coordinates and the spacing.
* Handle DTED and SRTM formats.
* \ingroup Images
*
*/
template <class TDEMImage, class TMapProjection>
class ITK_EXPORT DEMToOrthoImageGenerator:
public otb::DEMToImageGenerator<TDEMImage>
{
public :
/** Standard class typedefs. */
typedef itk::Indent Indent;
typedef TDEMImage DEMImageType;
typedef typename DEMImageType::Pointer DEMImagePointerType;
typedef typename DEMImageType::PixelType PixelType;
typedef TMapProjection MapProjectionType;
typedef typename MapProjectionType::Pointer MapProjectionPointerType;
typedef DEMToOrthoImageGenerator Self;
typedef otb::DEMToImageGenerator<DEMImageType> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef Image<PixelType,2> OutputImageType;
typedef typename Superclass::Pointer OutputImagePointer;
typedef typename OutputImageType::SpacingType SpacingType;
typedef typename OutputImageType::SizeType SizeType;
typedef typename OutputImageType::PointType PointType;
typedef typename OutputImageType::IndexType IndexType;
typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
typedef itk::ImageRegionIteratorWithIndex< DEMImageType > ImageIteratorType;
typedef otb::DEMHandler DEMHandlerType;
typedef typename DEMHandlerType::Pointer DEMHandlerPointerType;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(DEMToOrthoImageGenerator,ImageSource);
/** Set/Get the Output Origin coordinates. */
itkSetMacro(OutputOrigin,PointType);
itkGetConstReferenceMacro(OutputOrigin,PointType);
/** Set/Get the Output Size. */
itkSetMacro(OutputSize,SizeType);
itkGetConstReferenceMacro(OutputSize,SizeType);
/** Set/Get the Output Spacing. */
itkSetMacro(OutputSpacing,SpacingType);
itkGetConstReferenceMacro(OutputSpacing,SpacingType);
/** Set/Get the Default Unknown Value. */
itkSetMacro(DefaultUnknownValue,PixelType);
itkGetConstReferenceMacro(DefaultUnknownValue,PixelType);
/** Set/Get the projection*/
itkSetMacro(MapProjection, MapProjectionPointerType);
itkGetMacro(MapProjection, MapProjectionPointerType);
protected:
DEMToOrthoImageGenerator();
~DEMToOrthoImageGenerator();
void PrintSelf(std::ostream& os, Indent indent) const;
void GenerateData();
virtual void GenerateOutputInformation();
DEMHandlerPointerType m_DEMHandler;
PointType m_OutputOrigin;
SpacingType m_OutputSpacing;
SizeType m_OutputSize;
PixelType m_DefaultUnknownValue;
MapProjectionPointerType m_MapProjection;
private:
DEMToOrthoImageGenerator(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
};
} // namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbDEMToOrthoImageGenerator.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 __otbDEMToOrthoImageGenerator_txx
#define __otbDEMToOrthoImageGenerator_txx
#include "otbDEMToOrthoImageGenerator.h"
#include "otbMacro.h"
namespace otb
{
template<class TDEMImage, class TMapProjection>
DEMToOrthoImageGenerator<TDEMImage, TMapProjection>
::DEMToOrthoImageGenerator()
{
m_DEMHandler = DEMHandlerType::New();
m_OutputSpacing[0]=0.0001;
m_OutputSpacing[1]=-0.0001;
m_OutputSize[0]=1;
m_OutputSize[1]=1;
m_OutputOrigin[0]=0;
m_OutputOrigin[1]=0;
m_DefaultUnknownValue = static_cast<PixelType>(-32768); // Value defined in the norm for points strm doesn't have information.
m_MapProjection = NULL;
}
template<class TDEMImage, class TMapProjection>
DEMToOrthoImageGenerator<TDEMImage, TMapProjection>
::~DEMToOrthoImageGenerator()
{
// Nothing to be done...
}
// GenerateOutputInformation method
template <class TDEMImage, class TMapProjection>
void DEMToOrthoImageGenerator<TDEMImage, TMapProjection>
::GenerateOutputInformation()
{
DEMImageType *output;
output = this->GetOutput(0);
IndexType start;
start[0]=0;
start[1]=0;
// Specify region parameters
OutputImageRegionType largestPossibleRegion;
largestPossibleRegion.SetSize( m_OutputSize );
largestPossibleRegion.SetIndex( start );
output->SetLargestPossibleRegion( largestPossibleRegion );
output->SetSpacing(m_OutputSpacing);
output->SetOrigin(m_OutputOrigin);
}
// GenerateData method
template <class TDEMImage, class TMapProjection>
void
DEMToOrthoImageGenerator<TDEMImage, TMapProjection>
::GenerateData()
{
if(!m_MapProjection)
{
itkExceptionMacro( <<
"Please set map projection!" );
}
DEMImagePointerType DEMImage = this->GetOutput();
// allocate the output buffer
DEMImage->SetBufferedRegion( DEMImage->GetRequestedRegion() );
DEMImage->Allocate();
DEMImage->FillBuffer(0);
// Create an iterator that will walk the output region
ImageIteratorType outIt = ImageIteratorType(DEMImage,DEMImage->GetRequestedRegion());
// Walk the output image, evaluating the height at each pixel
IndexType currentindex;
PointType cartoPoint;
double height;
PointType geoPoint;
for (outIt.GoToBegin(); !outIt.IsAtEnd(); ++outIt)
{
currentindex=outIt.GetIndex();
DEMImage->TransformIndexToPhysicalPoint(currentindex, cartoPoint);
otbMsgDevMacro(<< "CartoPoint : (" << cartoPoint[0] << "," << cartoPoint[1] << ")") ;
geoPoint = m_MapProjection->TransformPoint(cartoPoint);
otbMsgDevMacro(<< "CartoPoint : (" << geoPoint[0] << "," << geoPoint[1] << ")") ;
height=m_DEMHandler->GetHeightAboveMSL(geoPoint); // Altitude calculation
otbMsgDevMacro(<< "height" << height) ;
// MNT sets a default value (-32768) at point where it doesn't have altitude information.
// OSSIM has chosen to change this default value in OSSIM_DBL_NAN (-4.5036e15).
if (!ossim::isnan(height))
{
// Fill the image
DEMImage->SetPixel(currentindex, static_cast<PixelType>(height) );
}
else
{
// Back to the MNT default value
DEMImage->SetPixel(currentindex, m_DefaultUnknownValue);
}
}
}
template <class TDEMImage, class TMapProjection>
void
DEMToOrthoImageGenerator<TDEMImage, TMapProjection>
::PrintSelf(std::ostream& os, Indent indent) const
{
Superclass::PrintSelf(os,indent);
os << indent << "Output Spacing:"<< m_OutputSpacing[0] << ","<< m_OutputSpacing[1] << std::endl;
os << indent << "Output Origin:"<< m_OutputOrigin[0] << ","<< m_OutputOrigin[1] << std::endl;
os << indent << "Output Size:"<< m_OutputSize[0] << ","<< m_OutputSize[1] << std::endl;
}
} // namespace otb
#endif
......@@ -30,7 +30,7 @@ namespace otb
{
/** \class ImageKeywordlist
* \brief Stockage/Conversion des MetaDonnees OSSIM
* \brief Storage and conversion for OSSIM metadata
*
* \sa ImageSeriesReader
* \sa ImageIOBase
......
......@@ -55,7 +55,7 @@ PURPOSE. See the above copyright notices for more information.
#include "otbTransMercatorMapProjection.h"
#include "otbSinusoidalMapProjection.h"
#include "otbMollweidMapProjection.h"
#include "otbSVY21MapProjection.h"
namespace otb
{
......@@ -86,6 +86,8 @@ namespace otb
typedef Lambert2EtenduProjection<FORWARD> Lambert2EtenduForwardProjection;
typedef Lambert93Projection<INVERSE> Lambert93InverseProjection;
typedef Lambert93Projection<FORWARD> Lambert93ForwardProjection;
typedef SVY21MapProjection<INVERSE> SVY21InverseProjection;
typedef SVY21MapProjection<FORWARD> SVY21ForwardProjection;
typedef MapProjection<ossimLlxyProjection,INVERSE> LlxyInverseProjection;
typedef MapProjection<ossimLlxyProjection,FORWARD> LlxyForwardProjection;
typedef MapProjection<ossimEquDistCylProjection,INVERSE> EquDistCylInverseProjection;
......
/*=========================================================================
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 __otbSVY21MapProjection_h
#define __otbSVY21MapProjection_h
#include "projection/ossimMapProjection.h"
#include "projection/ossimTransMercatorProjection.h"
#include "otbMapProjection.h"
namespace otb
{
/** \class SVY21MapProjection
* \brief This class implements the SVY21 map projection (Singapore geodesic system).
* It converts coordinates in longitude,latitude (WGS84) to SVY21 map coordinates.
*
*/
template <InverseOrForwardTransformationEnum transform>
class ITK_EXPORT SVY21MapProjection : public TransMercatorMapProjection<transform>
{
public :
/** Standard class typedefs. */
typedef SVY21MapProjection Self;
typedef TransMercatorMapProjection<transform> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef typename Superclass::ScalarType ScalarType;
typedef itk::Point<ScalarType,2 > InputPointType;
typedef itk::Point<ScalarType,2 > OutputPointType;
/** Method for creation through the object factory. */
itkNewMacro( Self );
/** Run-time type information (and related methods). */
itkTypeMacro( SVY21MapProjection, MapProjection );
protected:
SVY21MapProjection();
virtual ~SVY21MapProjection();
private :
SVY21MapProjection(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
};
} // namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbSVY21MapProjection.txx"
#endif
#endif
/*=========================================================================
Program: ORFEO Toolbox
Language: C++