Commit 41bb75da authored by OTB Bot's avatar OTB Bot

STYLE

parent 22110c0d
......@@ -23,7 +23,6 @@
#define ITK_LEAN_AND_MEAN
#endif
// Software Guide : BeginCommandLineArgs
// OUTPUTS: {DEMToRainbowImageGenerator.png}
// 6.5 45.5 500 500 0.002 -0.002 ${OTB_DATA_ROOT}/Examples/DEM_srtm
......@@ -54,7 +53,6 @@
//
// Software Guide : EndLatex
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbStreamingImageFileWriter.h"
......@@ -67,14 +65,15 @@
int main(int argc, char * argv[])
{
if (argc<9)
{
std::cout << argv[0] <<" <output_filename> <Longitude Output Origin point>";
std::cout << " <Latitude Output Origin point> <X Output Size> <Y Output size>";
if (argc < 9)
{
std::cout << argv[0] <<
" <output_filename> <Longitude Output Origin point>";
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;
}
}
typedef double PixelType;
typedef unsigned char UCharPixelType;
......@@ -86,15 +85,14 @@ int main(int argc, char * argv[])
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(argv[1]);
typedef otb::DEMToImageGenerator<ImageType> DEMToImageGeneratorType;
typedef otb::DEMToImageGenerator<ImageType> DEMToImageGeneratorType;
DEMToImageGeneratorType::Pointer demToImage = DEMToImageGeneratorType::New();
typedef DEMToImageGeneratorType::SizeType SizeType;
typedef DEMToImageGeneratorType::SpacingType SpacingType;
typedef DEMToImageGeneratorType::DEMHandlerType DEMHandlerType;
typedef DEMHandlerType::PointType PointType;
typedef DEMToImageGeneratorType::SizeType SizeType;
typedef DEMToImageGeneratorType::SpacingType SpacingType;
typedef DEMToImageGeneratorType::DEMHandlerType DEMHandlerType;
typedef DEMHandlerType::PointType PointType;
demToImage->SetDEMDirectoryPath(argv[8]);
......@@ -125,62 +123,67 @@ int main(int argc, char * argv[])
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef itk::ScalarToRGBColormapImageFilter<ImageType,RGBImageType> ColorMapFilterType;
typedef itk::ScalarToRGBColormapImageFilter<ImageType,
RGBImageType> ColorMapFilterType;
ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();
colormapper->UseInputImageExtremaForScalingOff();
if (argc == 9)
{
typedef otb::Functor::ScalarToRainbowRGBPixelFunctor<PixelType, RGBPixelType> ColorMapFunctorType;
{
typedef otb::Functor::ScalarToRainbowRGBPixelFunctor<PixelType,
RGBPixelType>
ColorMapFunctorType;
ColorMapFunctorType::Pointer colormap = ColorMapFunctorType::New();
colormap->SetMinimumInputValue(0);
colormap->SetMaximumInputValue(4000);
colormapper->SetColormap(colormap);
}
}
// Software Guide : EndCodeSnippet
else
{
if (strcmp(argv[9],"hot") == 0)
{
typedef itk::Functor::HotColormapFunctor<PixelType, RGBPixelType> ColorMapFunctorType;
if (strcmp(argv[9], "hot") == 0)
{
typedef itk::Functor::HotColormapFunctor<PixelType,
RGBPixelType>
ColorMapFunctorType;
ColorMapFunctorType::Pointer colormap = ColorMapFunctorType::New();
colormap->SetMinimumInputValue(0);
colormap->SetMaximumInputValue(4000);
colormapper->SetColormap(colormap);
}
}
else
{
typedef otb::Functor::ReliefColormapFunctor<PixelType, RGBPixelType> ColorMapFunctorType;
{
typedef otb::Functor::ReliefColormapFunctor<PixelType,
RGBPixelType>
ColorMapFunctorType;
ColorMapFunctorType::Pointer colormap = ColorMapFunctorType::New();
colormap->SetMinimumInputValue(0);
colormap->SetMaximumInputValue(4000);
colormapper->SetColormap(colormap);
}
}
}
// Software Guide : BeginCodeSnippet
colormapper->SetInput(demToImage->GetOutput());
// Software Guide : EndCodeSnippet
writer->SetInput(colormapper->GetOutput());
try
{
{
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
//
......@@ -188,16 +191,16 @@ int main(int argc, char * argv[])
// a gray level image.
//
// \begin{figure}
// \center
// \includegraphics[width=0.44\textwidth]{pretty_DEMToImageGenerator.eps}
// \includegraphics[width=0.44\textwidth]{DEMToRainbowImageGenerator.eps}
// \includegraphics[width=0.44\textwidth]{DEMToHotImageGenerator.eps}
// \includegraphics[width=0.44\textwidth]{DEMToReliefImageGenerator.eps}
// \itkcaption[Grayscale to color]{The gray level DEM extracted from SRTM
// data (top-left) and the same area in color representation.}
// \label{fig:RAINBOW_FILTER}
// \end{figure}
// Software Guide : EndLatex
// \center
// \includegraphics[width=0.44\textwidth]{pretty_DEMToImageGenerator.eps}
// \includegraphics[width=0.44\textwidth]{DEMToRainbowImageGenerator.eps}
// \includegraphics[width=0.44\textwidth]{DEMToHotImageGenerator.eps}
// \includegraphics[width=0.44\textwidth]{DEMToReliefImageGenerator.eps}
// \itkcaption[Grayscale to color]{The gray level DEM extracted from SRTM
// data (top-left) and the same area in color representation.}
// \label{fig:RAINBOW_FILTER}
// \end{figure}
// Software Guide : EndLatex
return EXIT_SUCCESS;
}
......@@ -68,21 +68,20 @@
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
int main( int argc, char * argv[] )
int main(int argc, char * argv[])
{
if ( argc != 5 )
{
if (argc != 5)
{
std::cerr << "Usage: " << argv[0] << " inputImageFile ";
std::cerr << " outputImageFile radius deramp" << std::endl;
return EXIT_FAILURE;
}
}
typedef unsigned char PixelType;
typedef otb::Image< PixelType, 2 > InputImageType;
typedef otb::Image< PixelType, 2 > OutputImageType;
typedef unsigned char PixelType;
typedef otb::Image<PixelType, 2> InputImageType;
typedef otb::Image<PixelType, 2> OutputImageType;
// Software Guide : BeginLatex
//
......@@ -91,22 +90,19 @@ int main( int argc, char * argv[] )
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::FrostImageFilter< InputImageType, OutputImageType > FilterType;
typedef otb::FrostImageFilter<InputImageType, OutputImageType> FilterType;
// Software Guide : EndCodeSnippet
typedef otb::ImageFileReader<InputImageType> ReaderType;
typedef otb::ImageFileReader< InputImageType > ReaderType;
typedef otb::ImageFileWriter< OutputImageType > WriterType;
typedef otb::ImageFileWriter<OutputImageType> WriterType;
ReaderType::Pointer reader = ReaderType::New();
FilterType::Pointer filter = FilterType::New();
WriterType::Pointer writer = WriterType::New();
writer->SetInput( filter->GetOutput() );
reader->SetFileName( argv[1] );
writer->SetInput(filter->GetOutput());
reader->SetFileName(argv[1]);
// Software Guide : BeginLatex
//
......@@ -119,10 +115,9 @@ int main( int argc, char * argv[] )
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
filter->SetInput( reader->GetOutput() );
filter->SetInput(reader->GetOutput());
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The method \code{SetRadius()} defines the size of the window to
......@@ -137,14 +132,13 @@ int main( int argc, char * argv[] )
// Software Guide : BeginCodeSnippet
FilterType::SizeType Radius;
Radius[0]= atoi(argv[3]);
Radius[1]= atoi(argv[3]);
Radius[0] = atoi(argv[3]);
Radius[1] = atoi(argv[3]);
filter->SetRadius( Radius );
filter->SetDeramp( atof(argv[4]) );
filter->SetRadius(Radius);
filter->SetDeramp(atof(argv[4]));
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The filter is executed by invoking the \code{Update()} method. If the
......@@ -158,11 +152,9 @@ int main( int argc, char * argv[] )
filter->Update();
// Software Guide : EndCodeSnippet
writer->SetFileName( argv[2] );
writer->SetFileName(argv[2]);
writer->Update();
// Software Guide : BeginLatex
// Figure~\ref{fig:FROST_FILTER} shows the result of applying the Frost
// filter to a SAR image.
......@@ -182,7 +174,5 @@ int main( int argc, char * argv[] )
//
// Software Guide : EndLatex
return EXIT_SUCCESS;
}
......@@ -23,7 +23,6 @@
#define ITK_LEAN_AND_MEAN
#endif
// Software Guide : BeginCommandLineArgs
// OUTPUTS: {HillShadingExample.png}, {HillShadingColorExample.png}
// 6.5 45.5 500 500 0.002 -0.002 ${OTB_DATA_ROOT}/Examples/DEM_srtm
......@@ -45,7 +44,6 @@
//
// Software Guide : EndLatex
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbStreamingImageFileWriter.h"
......@@ -65,14 +63,14 @@ int main(int argc, char * argv[])
{
if (argc != 10)
{
std::cout << argv[0] <<" <output_filename> <output_color_filename> ";
std::cout << " <Longitude Output Origin point> <Latitude Output Origin point>";
{
std::cout << argv[0] << " <output_filename> <output_color_filename> ";
std::cout <<
" <Longitude Output Origin point> <Latitude Output Origin point>";
std::cout << " <X Output Size> <Y Output size>";
std::cout << " <X Spacing> <Y Spacing> <DEM folder path>" << std::endl;
return EXIT_FAILURE;
}
}
typedef double PixelType;
typedef unsigned char UCharPixelType;
......@@ -89,14 +87,14 @@ int main(int argc, char * argv[])
WriterType::Pointer writer2 = WriterType::New();
writer2->SetFileName(argv[2]);
typedef otb::DEMToImageGenerator<ImageType> DEMToImageGeneratorType;
typedef otb::DEMToImageGenerator<ImageType> DEMToImageGeneratorType;
DEMToImageGeneratorType::Pointer demToImage = DEMToImageGeneratorType::New();
typedef DEMToImageGeneratorType::SizeType SizeType;
typedef DEMToImageGeneratorType::SpacingType SpacingType;
typedef DEMToImageGeneratorType::DEMHandlerType DEMHandlerType;
typedef DEMHandlerType::PointType PointType;
typedef DEMToImageGeneratorType::SizeType SizeType;
typedef DEMToImageGeneratorType::SpacingType SpacingType;
typedef DEMToImageGeneratorType::DEMHandlerType DEMHandlerType;
typedef DEMHandlerType::PointType PointType;
demToImage->SetDEMDirectoryPath(argv[9]);
......@@ -120,12 +118,12 @@ int main(int argc, char * argv[])
//Compute the resolution (Vincenty formula)
double lon1 = origin[0];
double lon2 = origin[0]+size[0]*spacing[0];
double lon2 = origin[0] + size[0] * spacing[0];
double lat1 = origin[1];
double lat2 = origin[1]+size[1]*spacing[1];
double lat2 = origin[1] + size[1] * spacing[1];
double R = 6371; // km
double d = vcl_acos(vcl_sin(lat1)*vcl_sin(lat2) +
vcl_cos(lat1)*vcl_cos(lat2) * vcl_cos(lon2-lon1)) * R;
double d = vcl_acos(vcl_sin(lat1) * vcl_sin(lat2) +
vcl_cos(lat1) * vcl_cos(lat2) * vcl_cos(lon2 - lon1)) * R;
double res = d / vcl_sqrt(2.0);
// Software Guide : BeginLatex
......@@ -139,9 +137,13 @@ int main(int argc, char * argv[])
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef itk::ConstNeighborhoodIterator<ImageType> IterType;
typedef otb::Functor::HillShadingFunctor<IterType, ImageType, PixelType> FunctorType;
typedef otb::UnaryFunctorNeighborhoodImageFilter<ImageType, ImageType, FunctorType> HillShadingFilterType;
typedef itk::ConstNeighborhoodIterator<ImageType>
IterType;
typedef otb::Functor::HillShadingFunctor<IterType, ImageType,
PixelType> FunctorType;
typedef otb::UnaryFunctorNeighborhoodImageFilter<ImageType, ImageType,
FunctorType>
HillShadingFilterType;
HillShadingFilterType::Pointer hillShading = HillShadingFilterType::New();
hillShading->SetRadius(1);
hillShading->SetInput(demToImage->GetOutput());
......@@ -150,7 +152,6 @@ int main(int argc, char * argv[])
hillShading->GetFunctor().SetXRes(res);
hillShading->GetFunctor().SetYRes(res);
typedef itk::ShiftScaleImageFilter<ImageType, ScalarImageType> RescalerType;
RescalerType::Pointer rescaler = RescalerType::New();
rescaler->SetScale(255.0);
......@@ -158,12 +159,13 @@ int main(int argc, char * argv[])
writer->SetInput(rescaler->GetOutput());
typedef itk::ScalarToRGBColormapImageFilter<ImageType,RGBImageType> ColorMapFilterType;
typedef itk::ScalarToRGBColormapImageFilter<ImageType,
RGBImageType> ColorMapFilterType;
ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();
colormapper->UseInputImageExtremaForScalingOff();
typedef otb::Functor::ReliefColormapFunctor<PixelType, RGBPixelType> ColorMapFunctorType;
typedef otb::Functor::ReliefColormapFunctor<PixelType,
RGBPixelType> ColorMapFunctorType;
ColorMapFunctorType::Pointer colormap = ColorMapFunctorType::New();
colormap->SetMinimumInputValue(0);
colormap->SetMaximumInputValue(4000);
......@@ -171,32 +173,34 @@ int main(int argc, char * argv[])
colormapper->SetInput(demToImage->GetOutput());
typedef itk::BinaryFunctorImageFilter<RGBImageType, ImageType, RGBImageType,
otb::Functor::HillShadeModulationFunctor<RGBPixelType, PixelType, RGBPixelType> > MultiplyFilterType;
otb::Functor::
HillShadeModulationFunctor<RGBPixelType,
PixelType,
RGBPixelType> >
MultiplyFilterType;
MultiplyFilterType::Pointer multiply = MultiplyFilterType::New();
multiply->SetInput1(colormapper->GetOutput());
multiply->SetInput2(hillShading->GetOutput());
writer2->SetInput(multiply->GetOutput());
try
{
{
writer->Update();
writer2->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;
}
}
otb::WorldFile::Pointer worldFile = otb::WorldFile::New();
worldFile->SetLonOrigin(origin[0]);
......
......@@ -55,18 +55,18 @@
int main(int argc, char * argv[])
{
if ( argc != 4 )
{
if (argc != 4)
{
std::cerr << "Usage: " << argv[0] << " <inputImageFile> ";
std::cerr << " <outputRGBImageFile> <outputScaledImageFile>" << std::endl;
return EXIT_FAILURE;
}
}
const char * inputFilename = argv[1];
const char * outputRGBFilename = argv[2];
const char * outputScaledFilename = argv[3];
typedef otb::Image<unsigned long, 2> ImageType;
typedef otb::Image<itk::RGBPixel<unsigned char>,2> RGBImageType;
typedef otb::Image<unsigned long, 2> ImageType;
typedef otb::Image<itk::RGBPixel<unsigned char>, 2> RGBImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
......@@ -82,8 +82,10 @@ int main(int argc, char * argv[])
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef itk::Functor::ScalarToRGBPixelFunctor<unsigned long> ColorMapFunctorType;
typedef itk::UnaryFunctorImageFilter<ImageType, RGBImageType, ColorMapFunctorType> ColorMapFilterType;
typedef itk::Functor::ScalarToRGBPixelFunctor<unsigned long>
ColorMapFunctorType;
typedef itk::UnaryFunctorImageFilter<ImageType, RGBImageType,
ColorMapFunctorType> ColorMapFilterType;
ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();
colormapper->SetInput(reader->GetOutput());
......@@ -96,10 +98,10 @@ int main(int argc, char * argv[])
writer->Update();
//The following is just to produce the input image for the software guide
typedef otb::Image<unsigned char, 2> OutputImageType;
typedef itk::RescaleIntensityImageFilter<ImageType, OutputImageType> RescalerType;
typedef otb::Image<unsigned char, 2> OutputImageType;
typedef itk::RescaleIntensityImageFilter<ImageType,
OutputImageType> RescalerType;
RescalerType::Pointer rescaler = RescalerType::New();
rescaler->SetInput(reader->GetOutput());
......@@ -125,4 +127,3 @@ int main(int argc, char * argv[])
return EXIT_SUCCESS;
}
......@@ -51,15 +51,15 @@
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
int main( int argc, char * argv[] )
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
//
......@@ -68,7 +68,7 @@ int main( int argc, char * argv[] )
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef unsigned char PixelType;
typedef unsigned char PixelType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
......@@ -78,11 +78,10 @@ int main( int argc, char * argv[] )
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::Image< PixelType, 2 > InputImageType;
typedef otb::Image< PixelType, 2 > OutputImageType;
typedef otb::Image<PixelType, 2> InputImageType;
typedef otb::Image<PixelType, 2> OutputImageType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The filter can be instantiated using the image types defined above.
......@@ -90,10 +89,9 @@ int main( int argc, char * argv[] )
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::LeeImageFilter< InputImageType, OutputImageType > FilterType;
typedef otb::LeeImageFilter<InputImageType, OutputImageType> FilterType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// An \doxygen{otb}{ImageFileReader} class is also instantiated in order to read
......@@ -102,7 +100,7 @@ int main( int argc, char * argv[] )
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::ImageFileReader< InputImageType > ReaderType;
typedef otb::ImageFileReader<InputImageType> ReaderType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
......@@ -113,10 +111,9 @@ int main( int argc, char * argv[] )
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::ImageFileWriter< OutputImageType > WriterType;
typedef otb::ImageFileWriter<OutputImageType> WriterType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Both the filter and the reader are created by invoking their \code{New()}
......@@ -130,9 +127,8 @@ int main( int argc, char * argv[] )
// Software Guide : EndCodeSnippet
WriterType::Pointer writer = WriterType::New();
writer->SetInput( filter->GetOutput() );
reader->SetFileName( argv[1] );
writer->SetInput(filter->GetOutput());
reader->SetFileName(argv[1]);
// Software Guide : BeginLatex
//
......@@ -145,10 +141,9 @@ int main( int argc, char * argv[] )
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
filter->SetInput( reader->GetOutput() );
filter->SetInput(reader->GetOutput());
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The method \code{SetRadius()} defines the size of the window to
......@@ -164,14 +159,13 @@ int main( int argc, char * argv[] )
// Software Guide : BeginCodeSnippet
FilterType::SizeType Radius;
Radius[0]= atoi(argv[3]);
Radius[1]= atoi(argv[3]);
Radius[0] = atoi(argv[3]);
Radius[1] = atoi(argv[3]);
filter->SetRadius( Radius );
filter->SetNbLooks( atoi(argv[4]) );
filter->SetRadius(Radius);
filter->SetNbLooks(atoi(argv[4]));
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The filter is executed by invoking the \code{Update()} method. If the
......@@ -185,11 +179,9 @@ int main( int argc, char * argv[] )
filter->Update();
// Software Guide : EndCodeSnippet