Commit 7e71c7e2 authored by Emmanuel Christophe's avatar Emmanuel Christophe

STYLE: formatting indentation (Example)

parent 919468e8
......@@ -59,11 +59,11 @@
int main(int argc, char * argv[])
{
if(argc<9)
if (argc<9)
{
std::cout << argv[0] <<" <output_filename> <Longitude Output Orign point>";
std::cout << " <Latitude Output Origin point> <X Output Size> <Y Output size>";
std::cout << " <X Spacing> <Y Spacing> <DEM folder path>" << std::endl;
std::cout << " <Latitude Output Origin point> <X Output Size> <Y Output size>";
std::cout << " <X Spacing> <Y Spacing> <DEM folder path>" << std::endl;
return EXIT_FAILURE;
}
......@@ -119,7 +119,7 @@ int main(int argc, char * argv[])
// Software Guide : BeginCodeSnippet
typedef otb::Functor::ScalarToRainbowRGBPixelFunctor<PixelType> ColorMapFunctorType;
typedef itk::UnaryFunctorImageFilter<ImageType,
RGBImageType, ColorMapFunctorType> ColorMapFilterType;
RGBImageType, ColorMapFunctorType> ColorMapFilterType;
ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();
colormapper->GetFunctor().SetMaximum(4000);
colormapper->GetFunctor().SetMinimum(0);
......@@ -135,23 +135,23 @@ int main(int argc, char * argv[])
{
writer->Update();
}
catch( itk::ExceptionObject & excep )
catch ( itk::ExceptionObject & excep )
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
}
catch( ... )
catch ( ... )
{
std::cout << "Unknown exception !" << std::endl;
return EXIT_FAILURE;
}
// Software Guide : BeginLatex
// Software Guide : BeginLatex
//
// Figure~\ref{fig:RAINBOW_FILTER} shows effect of applying the filter to
// a gray level image.
//
// \begin{figure}
// \begin{figure}
// \center
// \includegraphics[width=0.44\textwidth]{pretty_DEMToImageGenerator.eps}
// \includegraphics[width=0.44\textwidth]{DEMToRainbowImageGenerator.eps}
......@@ -159,7 +159,7 @@ int main(int argc, char * argv[])
// data (left) and the same area in color representation.}
// \label{fig:RAINBOW_FILTER}
// \end{figure}
// Software Guide : EndLatex
// Software Guide : EndLatex
return EXIT_SUCCESS;
}
......@@ -55,7 +55,7 @@
int main(int argc, char * argv[])
{
if( argc != 4 )
if ( argc != 4 )
{
std::cerr << "Usage: " << argv[0] << " <inputImageFile> ";
std::cerr << " <outputRGBImageFile> <outputScaledImageFile>" << std::endl;
......
......@@ -54,12 +54,12 @@
int main( int argc, char * argv[] )
{
if( argc != 5 )
{
if ( argc != 5 )
{
std::cerr << "Usage: " << argv[0] << " inputImageFile ";
std::cerr << " outputImageFile radius NbLooks" << std::endl;
return EXIT_FAILURE;
}
}
// Software Guide : BeginLatex
//
......
......@@ -66,11 +66,11 @@
// Software Guide : EndCodeSnippet
int main(int argc, char * argv[])
{
if(argc != 12)
{
std::cerr<<"Usage: "<<argv[0]<<" infname filteredfname clusteredfname labeledclusteredfname clusterboundariesfname filteredPretty clusteredPretty spatialRadius rangeRadius minregionsize scale"<<std::endl;
return EXIT_FAILURE;
}
if (argc != 12)
{
std::cerr<<"Usage: "<<argv[0]<<" infname filteredfname clusteredfname labeledclusteredfname clusterboundariesfname filteredPretty clusteredPretty spatialRadius rangeRadius minregionsize scale"<<std::endl;
return EXIT_FAILURE;
}
const char * infname = argv[1];
const char * filteredfname = argv[2];
......@@ -172,7 +172,7 @@ int main(int argc, char * argv[])
// Software Guide : BeginCodeSnippet
filter->SetScale(scale);
// Software Guide : EndCodeSnippet
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// We can now plug the pipeline and run it.
......@@ -218,7 +218,7 @@ int main(int argc, char * argv[])
typedef PrintableFilterType::OutputImageType OutputImageType;
typedef otb::StreamingImageFileWriter< OutputImageType >
PrettyWriterType;
PrettyWriterType;
PrettyWriterType::Pointer prettyWriter = PrettyWriterType::New();
printableImageFilter->SetInput( filter->GetOutput() );
......
......@@ -71,7 +71,7 @@
int main( int argc, char * argv[] )
{
if( argc != 6 )
if ( argc != 6 )
{
std::cerr << "Usage: " << argv[0] << " <inputImageFile> ";
std::cerr << " <outputImageFile> <RedBand> <GreenBand> <BlueBand>" << std::endl;
......@@ -110,7 +110,7 @@ int main( int argc, char * argv[] )
printableImageFilter->SetChannel(redChannelNumber);
printableImageFilter->SetChannel(greenChannelNumber);
printableImageFilter->SetChannel(blueChannelNumber);
// Software Guide : EndCodeSnippet
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
......@@ -119,7 +119,7 @@ int main( int argc, char * argv[] )
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
// Software Guide : BeginCodeSnippet
typedef PrintableFilterType::OutputImageType OutputImageType;
typedef otb::StreamingImageFileWriter< OutputImageType > WriterType;
// Software Guide : EndCodeSnippet
......
......@@ -47,7 +47,7 @@
int main( int argc, char * argv[] )
{
if( argc != 4 )
if ( argc != 4 )
{
std::cerr << "Usage: " << argv[0] << " <inputImageFile> ";
std::cerr << " <outputRescaledImageFile> <outputCastedImageFile>" << std::endl;
......
......@@ -25,13 +25,13 @@
void RegisterTests()
{
REGISTER_TEST(LeeImageFilterTest);
REGISTER_TEST(DEMToRainbowExampleTest);
REGISTER_TEST(ScalingFilterExampleTest);
REGISTER_TEST(PrintableImageFilterExample1Test);
REGISTER_TEST(PrintableImageFilterExample2Test);
REGISTER_TEST(IndexedToRGBExampleTest);
REGISTER_TEST(MeanShiftVectorImageFilterExampleTest);
REGISTER_TEST(LeeImageFilterTest);
REGISTER_TEST(DEMToRainbowExampleTest);
REGISTER_TEST(ScalingFilterExampleTest);
REGISTER_TEST(PrintableImageFilterExample1Test);
REGISTER_TEST(PrintableImageFilterExample2Test);
REGISTER_TEST(IndexedToRGBExampleTest);
REGISTER_TEST(MeanShiftVectorImageFilterExampleTest);
}
#undef main
......
......@@ -85,13 +85,13 @@ public:
TOutput result = 0.0;
for(unsigned long pos = 0; pos< itA.Size(); ++pos)
{
for (unsigned long pos = 0; pos< itA.Size(); ++pos)
{
result += static_cast<TOutput>(itA.GetPixel(pos)-itB.GetPixel(pos));
}
}
return static_cast<TOutput>( result/itA.Size() );
}
};
......@@ -118,22 +118,22 @@ public:
// Software Guide : BeginCodeSnippet
template <class TInputImage1, class TInputImage2, class TOutputImage>
class ITK_EXPORT MyChangeDetectorImageFilter :
public otb::BinaryFunctorNeighborhoodImageFilter<
TInputImage1,TInputImage2,TOutputImage,
MyChangeDetector<
typename itk::ConstNeighborhoodIterator<TInputImage1>,
typename itk::ConstNeighborhoodIterator<TInputImage2>,
typename TOutputImage::PixelType> >
public otb::BinaryFunctorNeighborhoodImageFilter<
TInputImage1,TInputImage2,TOutputImage,
MyChangeDetector<
typename itk::ConstNeighborhoodIterator<TInputImage1>,
typename itk::ConstNeighborhoodIterator<TInputImage2>,
typename TOutputImage::PixelType> >
{
public:
/** Standard class typedefs. */
typedef MyChangeDetectorImageFilter Self;
typedef typename otb::BinaryFunctorNeighborhoodImageFilter<
TInputImage1,TInputImage2,TOutputImage,
MyChangeDetector<
typename itk::ConstNeighborhoodIterator<TInputImage1>,
typename itk::ConstNeighborhoodIterator<TInputImage2>,
typename TOutputImage::PixelType>
TInputImage1,TInputImage2,TOutputImage,
MyChangeDetector<
typename itk::ConstNeighborhoodIterator<TInputImage1>,
typename itk::ConstNeighborhoodIterator<TInputImage2>,
typename TOutputImage::PixelType>
> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
......@@ -167,12 +167,12 @@ private:
int main(int argc, char* argv[] )
{
if( argc < 5 )
{
if ( argc < 5 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile1 inputImageFile2 radius outputImageFile " << std::endl;
return -1;
}
}
// Define the dimension of the images
const unsigned int Dimension = 2;
......@@ -208,7 +208,7 @@ int main(int argc, char* argv[] )
typedef otb::ImageFileReader< InputImageType2 > ReaderType2;
typedef otb::ImageFileWriter< OutputImageType > WriterType;
typedef itk::RescaleIntensityImageFilter< ChangeImageType,
OutputImageType > RescalerType;
OutputImageType > RescalerType;
// Software Guide : EndCodeSnippet
......@@ -220,9 +220,9 @@ int main(int argc, char* argv[] )
// Software Guide : BeginCodeSnippet
typedef MyChangeDetectorImageFilter<
InputImageType1,
InputImageType2,
ChangeImageType > FilterType;
InputImageType1,
InputImageType2,
ChangeImageType > FilterType;
// Software Guide : EndCodeSnippet
......@@ -266,15 +266,15 @@ int main(int argc, char* argv[] )
try
{
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
}
catch ( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
}
// Software Guide : BeginLatex
//
......
......@@ -57,12 +57,12 @@
int main(int argc, char* argv[] )
{
if( argc < 5 )
{
if ( argc < 5 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile1 inputImageFile2 outputImageFile radius" << std::endl;
return -1;
}
}
// Define the dimension of the images
const unsigned int Dimension = 2;
......@@ -110,7 +110,7 @@ int main(int argc, char* argv[] )
// Software Guide : BeginCodeSnippet
typedef itk::ShiftScaleImageFilter< ChangeImageType,
OutputImageType > RescalerType;
OutputImageType > RescalerType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
......@@ -123,9 +123,9 @@ int main(int argc, char* argv[] )
// Software Guide : BeginCodeSnippet
typedef otb::CorrelationChangeDetector<
InputImageType1,
InputImageType2,
ChangeImageType > FilterType;
InputImageType1,
InputImageType2,
ChangeImageType > FilterType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
......@@ -202,15 +202,15 @@ int main(int argc, char* argv[] )
try
{
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
}
catch ( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
}
// Software Guide : BeginLatex
// Figure \ref{fig:RESCORRCHDET} shows the result of the change
......
......@@ -72,12 +72,12 @@
int main(int argc, char* argv[] )
{
if( argc < 5 )
{
if ( argc < 5 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile1 inputImageFile2 outputImageFile radius" << std::endl;
return -1;
}
}
// Define the dimension of the images
const unsigned int Dimension = 2;
......@@ -124,9 +124,9 @@ int main(int argc, char* argv[] )
// Software Guide : BeginCodeSnippet
typedef itk::AbsImageFilter< ChangeImageType,
ChangeImageType > AbsType;
ChangeImageType > AbsType;
typedef itk::RescaleIntensityImageFilter< ChangeImageType,
OutputImageType > RescalerType;
OutputImageType > RescalerType;
// Software Guide : EndCodeSnippet
......@@ -140,9 +140,9 @@ int main(int argc, char* argv[] )
// Software Guide : BeginCodeSnippet
typedef otb::MeanDifferenceImageFilter<
InputImageType1,
InputImageType2,
ChangeImageType > FilterType;
InputImageType1,
InputImageType2,
ChangeImageType > FilterType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
......@@ -222,15 +222,15 @@ int main(int argc, char* argv[] )
try
{
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
}
catch ( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
}
// Software Guide : BeginLatex
// Figure \ref{fig:RESDIFFCHDET} shows the result of the change
// detection by difference of local means.
......
......@@ -26,12 +26,12 @@
int main(int argc, char* argv[] )
{
if( argc < 5 )
{
if ( argc < 5 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile1 inputImageFile2 radius outputImageFile " << std::endl;
return -1;
}
}
// Define the dimension of the images
const unsigned int Dimension = 2;
......@@ -49,15 +49,15 @@ int main(int argc, char* argv[] )
typedef otb::StreamingImageFileWriter< OutputImageType > WriterType;
typedef itk::ShiftScaleImageFilter< ChangeImageType,
OutputImageType > RescalerType;
OutputImageType > RescalerType;
// Declare the type for the filter
typedef otb::JoinHistogramMIImageFilter<
InputImageType1,
InputImageType2,
ChangeImageType > FilterType;
InputImageType1,
InputImageType2,
ChangeImageType > FilterType;
ReaderType1::Pointer reader1 = ReaderType1::New();
......@@ -78,8 +78,8 @@ int main(int argc, char* argv[] )
rescaler->SetShift( itk::NumericTraits< InternalPixelType >::min());
float scale = itk::NumericTraits< OutputPixelType >::max()/ 100.0;
/*float(itk::NumericTraits< OutputPixelType >::max()+
itk::NumericTraits< InternalPixelType >::min());*/
/*float(itk::NumericTraits< OutputPixelType >::max()+
itk::NumericTraits< InternalPixelType >::min());*/
rescaler->SetScale( scale );
......@@ -101,15 +101,15 @@ int main(int argc, char* argv[] )
try
{
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
}
catch ( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
}
return EXIT_SUCCESS;
......
......@@ -10,8 +10,8 @@
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
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.
=========================================================================*/
......@@ -25,25 +25,25 @@
// Software Guide : BeginLatex
// This example illustrates the class
// \doxygen{otb}{KullbackLeiblerDistanceImageFilter} for detecting changes
// between pairs of images. This filter computes the Kullback-Leibler
// between pairs of images. This filter computes the Kullback-Leibler
// distance between probability density functions (pdfs).
// In fact, the Kullback-Leibler distance is itself approximated through
// a cumulant-based expansion, since the pdfs are approximated through an
// a cumulant-based expansion, since the pdfs are approximated through an
// Edgeworth series.
// The Kullback-Leibler distance is evaluated by:
// The Kullback-Leibler distance is evaluated by:
// \begin{multline}\label{eqKLapprox1D}
// K_{\text{Edgeworth}}(X_1 | X_2) = \frac{1}{12} \frac{\kappa_{X_1;3}^2}{\kappa_{X_1;2}^2}
// + \frac{1}{2} \left( \log \frac{\kappa_{X_2;2}}{\kappa_{X_1;2}}
// -1+\frac{1}{\kappa_{X_2;2}}
// -1+\frac{1}{\kappa_{X_2;2}}
// \left( \kappa_{X_1;1} - \kappa_{X_2;1} + \kappa_{X_1;2}^{1/2} \right)^2
// \right) \\
// - \left( \kappa_{X_2;3} \frac{a_1}{6} + \kappa_{X_2;4} \frac{a_2}{24}
// + \kappa_{X_2;3}^2 \frac{a_3}{72} \right)
// - \frac{1}{2} \frac{ \kappa_{X_2;3}^2}{36}
// + \kappa_{X_2;3}^2 \frac{a_3}{72} \right)
// - \frac{1}{2} \frac{ \kappa_{X_2;3}^2}{36}
// \left(
// c_6 - 6 \frac{c_4}{\kappa_{X_1;2}} + 9 \frac{c_2}{\kappa_{X_2;2}^2}
// \right) \\
// - 10 \frac{\kappa_{X_1;3} \kappa_{X_2;3}
// - 10 \frac{\kappa_{X_1;3} \kappa_{X_2;3}
// \left( \kappa_{X_1;1} - \kappa_{X_2;1} \right)
// \left( \kappa_{X_1;2} - \kappa_{X_2;2} \right)}{\kappa_{X_2;2}^6} \qquad
// \end{multline}
......@@ -60,16 +60,16 @@
// \alpha &= \frac{\kappa_{X_1;1} - \kappa_{X_2;1}}{\kappa_{X_2;2}} \\
// \beta &= \frac{ \kappa_{X_1;2}^{1/2} }{\kappa_{X_2;2}}.
// \end{align*}
// $\kappa_{X_i;1}$, $\kappa_{X_i;2}$, $\kappa_{X_i;3}$ and $\kappa_{X_i;4}$
// $\kappa_{X_i;1}$, $\kappa_{X_i;2}$, $\kappa_{X_i;3}$ and $\kappa_{X_i;4}$
// are the cumulants up to order 4 of the random variable $X_i$ ($i=1,2$).
// This example will use the images shown in
// figure~\ref{fig:RATCHDETINIM}. These correspond to 2 Radarsat fine
// mode acquisitions before and after a lava flow resulting from a
// volcanic eruption.
//
// The program itself is very similar to the ratio of means detector,
// implemented in \doxygen{otb}{MeanRatioImageFilter},
// in section~\ref{sec:RatioOfMeans}. Nevertheless
// The program itself is very similar to the ratio of means detector,
// implemented in \doxygen{otb}{MeanRatioImageFilter},
// in section~\ref{sec:RatioOfMeans}. Nevertheless
// the corresponding header file has to be used instead.
//
// Software Guide : EndLatex
......@@ -88,8 +88,8 @@
int main(int argc, char * argv[])
{
try
{
if(argc != 5)
{
if (argc != 5)
{
std::cerr<<"Change detection through a Kullback-Leibler measure (which is a distance between local distributions)\n";
std::cerr<<"Kullback-Leibler measure is optimized by a Edgeworth series expansion\n";
......@@ -97,115 +97,115 @@ int main(int argc, char * argv[])
return 1;
}
char * fileName1 = argv[1];
char * fileName2 = argv[2];
char * fileNameOut = argv[3];
int winSize = atoi(argv[4]);
const unsigned int Dimension = 2;
typedef double PixelType;
typedef unsigned char OutputPixelType;
typedef otb::Image<PixelType,Dimension> ImageType;
typedef otb::Image<OutputPixelType,Dimension> OutputImageType;
// Software Guide : BeginLatex
//
// The \doxygen{otb}{KullbackLeiblerDistanceImageFilter} is templated over
// the types of the two input images and the type of the generated change
// image, in a similar way as the \doxygen{otb}{MeanRatioImageFilter}. It is
// the only line to be changed from the ratio of means change detection
// example to perform a change detection through a distance between
// distributions...
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::KullbackLeiblerDistanceImageFilter<ImageType,
ImageType,ImageType> FilterType;
// Software Guide : EndCodeSnippet