diff --git a/Code/BasicFilters/otbMeanShiftImageFilter.h b/Code/BasicFilters/otbMeanShiftImageFilter.h index 4ded01df843ac29f292b1d58c03f860c6f00bca2..9b2797ffb4432752c2eeb9682137c219d967c184 100644 --- a/Code/BasicFilters/otbMeanShiftImageFilter.h +++ b/Code/BasicFilters/otbMeanShiftImageFilter.h @@ -67,7 +67,7 @@ namespace otb * 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 * GetClusteredOuptut() methods returns the clustered output. The GetLabeledClusteredOutput() returns - * a labeled clustered images, and the GetClusterBoundariesOutput() + * a labeled clustered image, and the GetClusterBoundariesOutput() * an image of the cluster boundaries. * * The MinimumRegionSize parameter allows you to prune small clustered regions. diff --git a/Code/BasicFilters/otbMeanShiftVectorImageFilter.h b/Code/BasicFilters/otbMeanShiftVectorImageFilter.h index b0f77638197dd680fa8b697a55d0c8901d75b977..d0e542e12d22b2b7703a979e7fcef4996b3e375d 100644 --- a/Code/BasicFilters/otbMeanShiftVectorImageFilter.h +++ b/Code/BasicFilters/otbMeanShiftVectorImageFilter.h @@ -59,7 +59,7 @@ namespace otb * * 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::MeanShiftImageFilterBase. + * base class otb::MeanShiftImageFilter. * * \sa MeanShiftImageFilter * \ingroup ImageEnhancement diff --git a/Examples/BasicFilters/CMakeLists.txt b/Examples/BasicFilters/CMakeLists.txt index b111577f0c3d80d360919d09d4f737824ecf423c..ff9ea4483997cb0a31baaa4f0cb0ae4852b30d16 100644 --- a/Examples/BasicFilters/CMakeLists.txt +++ b/Examples/BasicFilters/CMakeLists.txt @@ -16,6 +16,10 @@ TARGET_LINK_LIBRARIES(PrintableImageFilterExample OTBCommon OTBIO) ADD_EXECUTABLE(IndexedToRGBExample IndexedToRGBExample.cxx ) TARGET_LINK_LIBRARIES(IndexedToRGBExample OTBCommon OTBIO) +ADD_EXECUTABLE(MeanShiftVectorImageFilterExample MeanShiftVectorImageFilterExample.cxx ) +TARGET_LINK_LIBRARIES(MeanShiftVectorImageFilterExample OTBCommon OTBIO OTBBasicFilters) + + IF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING ) SET(BASELINE ${OTB_DATA_ROOT}/Baseline/Examples/BasicFilters) diff --git a/Examples/BasicFilters/IndexedToRGBExample.cxx b/Examples/BasicFilters/IndexedToRGBExample.cxx index ab619b81901122a6bfcf63d1d5fe980ca3f8ad5b..4c99cbb7e10e8f2399e1414d1ad192918122d26b 100644 --- a/Examples/BasicFilters/IndexedToRGBExample.cxx +++ b/Examples/BasicFilters/IndexedToRGBExample.cxx @@ -30,7 +30,7 @@ // Software Guide : BeginLatex // -// Some algorithm produces as an output an indexed image. In such images, +// Some algorithms produce as an output an indexed image. In such images, // each pixel is given a value according to the region number it belongs to. // This value starting at 0 or 1 is usually an integer value. // Often, such images are produced by segmentation or classification algorithm. diff --git a/Examples/BasicFilters/MeanShiftVectorImageFilterExample.cxx b/Examples/BasicFilters/MeanShiftVectorImageFilterExample.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d30b66bf24be831d16affc7b09c885a40672105a --- /dev/null +++ b/Examples/BasicFilters/MeanShiftVectorImageFilterExample.cxx @@ -0,0 +1,221 @@ +/*========================================================================= + + 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. + +=========================================================================*/ + +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#ifdef __BORLANDC__ +#define ITK_LEAN_AND_MEAN +#endif + +// Software Guide : BeginCommandLineArgs +// INPUTS: {ROI_QB_MUL_1.png} +// OUTPUTS: {MSFilteredOutput.png}, {MSClusteredOutput.png}, {MSLabelledOutput.png}, {MSBoundariesOutput.png} +// 5 50 20 +// Software Guide : EndCommandLineArgs + +// Software Guide : BeginLatex +// +// This example demonstrates the use of the +// \doxygen{otb}{MeanShiftVectorImageFilter} class which implements +// filtering and clustering using the mean shift algorithm +// \cite{Comaniciu2002}. // For a given pixel, the mean shift will +// build a set of neighboring pixels within a given spatial radius +// and a color range. The spatial and color center of this set is +// then computed and the algorithm iterates with this new spatial and +// color center. The Mean shift can be used for edge-preserving +// smoothing, or for clustering. +// +// Software Guide : EndLatex + +#include "itkExceptionObject.h" +#include "otbVectorImage.h" +#include "otbImageFileReader.h" +#include "otbStreamingImageFileWriter.h" +#include "otbPrintableImageFilter.h" + +// Software Guide : BeginLatex +// +// Two implementations for the filter exist, one for scalar images +// (\doxygen{otb}{MeanShiftImageFilter}). And another one (the one +// presented in this example) for vector images. They have the same +// interface, so they can be used in the same way. We start by +// including the needed header file. +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet +#include "otbMeanShiftVectorImageFilter.h" +// 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; + } + + const char * infname = argv[1]; + const char * filteredfname = argv[2]; + const char * clusteredfname = argv[3]; + const char * labeledclusteredfname = argv[4]; + const char * clusterboundariesfname = argv[5]; + const char * filteredPretty = argv[6]; + const char * clusteredPretty = argv[7]; + const unsigned int spatialRadius = atoi(argv[8]); + const double rangeRadius = atof(argv[9]); + const unsigned int minRegionSize = atoi(argv[10]); + const double scale = atoi(argv[11]); + + // Software Guide : BeginLatex +// +// We start by the classical \code{typedef}s needed for reading and +// writing the images. The EDISON code upon which OTB's +// implementation is based, uses float pixel precision, so we choose +// to work with a float pixel type. +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet + const unsigned int Dimension = 2; + typedef float PixelType; + typedef otb::VectorImage<PixelType,Dimension> ImageType; + typedef otb::ImageFileReader<ImageType> ReaderType; + typedef otb::StreamingImageFileWriter<ImageType> WriterType; +// Software Guide : EndCodeSnippet + + // Software Guide : BeginLatex +// +// We can now define the type for the filter, and also the type for +// the labeled output image, which is needed for the corresponding writer: +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet + typedef otb::MeanShiftVectorImageFilter<ImageType,ImageType> FilterType; + typedef FilterType::LabeledOutputType LabeledImageType; + typedef otb::StreamingImageFileWriter<LabeledImageType> LabeledWriterType; + + // Software Guide : EndCodeSnippet + + // Software Guide : BeginLatex +// +// We instantiate the filter, the reader, and 4 writers (2 for the +// filetered and clustered images and 2 more for the labeled and +// boundaries images): +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet + FilterType::Pointer filter = FilterType::New(); + ReaderType::Pointer reader = ReaderType::New(); + WriterType::Pointer writer1 = WriterType::New(); + WriterType::Pointer writer2 = WriterType::New(); + LabeledWriterType::Pointer writer3 = LabeledWriterType::New(); + LabeledWriterType::Pointer writer4 = LabeledWriterType::New(); + + // Software Guide : EndCodeSnippet + + // Software Guide : BeginLatex +// +// We set the file names for the reader and the writers: +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet + reader->SetFileName(infname); + writer1->SetFileName(filteredfname); + writer2->SetFileName(clusteredfname); + writer3->SetFileName(labeledclusteredfname); + writer4->SetFileName(clusterboundariesfname); + + // Software Guide : EndCodeSnippet + + // Software Guide : BeginLatex +// +// We can now set the parameters for the filter. There are 3 main +// parameters: the spatial radius used for defining the neighborhood, +// the range radius used for defining the interval in the color space +// and the minimum size for the regions to be kept after clustering. +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet + filter->SetSpatialRadius(spatialRadius); + filter->SetRangeRadius(rangeRadius); + filter->SetMinimumRegionSize(minRegionSize); + // Software Guide : EndCodeSnippet + // Software Guide : BeginLatex +// +// OTB's implementation adds another parameter -- the scale -- which +// allows to stretch the image before processing. This is useful when +// pixel values are in the \[0-1\] range. +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet + filter->SetScale(scale); + // Software Guide : EndCodeSnippet + // Software Guide : BeginLatex +// +// We can now plug the pipeline and run it. +// +// Software Guide : EndLatex + +// Software Guide : BeginCodeSnippet + + filter->SetInput(reader->GetOutput()); + writer1->SetInput(filter->GetOutput()); + writer2->SetInput(filter->GetClusteredOutput()); + writer3->SetInput(filter->GetLabeledClusteredOutput()); + writer4->SetInput(filter->GetClusterBoundariesOutput()); + + + writer1->Update(); + writer2->Update(); + writer3->Update(); + writer4->Update(); + // Software Guide : EndCodeSnippet + + typedef otb::PrintableImageFilter< ImageType > PrintableFilterType; + PrintableFilterType::Pointer printableImageFilter = PrintableFilterType::New(); + + printableImageFilter->SetChannel(1); + printableImageFilter->SetChannel(2); + printableImageFilter->SetChannel(3); + + typedef PrintableFilterType::OutputImageType OutputImageType; + typedef otb::StreamingImageFileWriter< OutputImageType > + PrettyWriterType; + PrettyWriterType::Pointer prettyWriter = PrettyWriterType::New(); + + printableImageFilter->SetInput( filter->GetOutput() ); + prettyWriter->SetFileName( filteredPretty ); + prettyWriter->SetInput( printableImageFilter->GetOutput() ); + prettyWriter->Update(); + + printableImageFilter->SetInput( filter->GetClusteredOutput() ); + prettyWriter->SetFileName( clusteredPretty ); + prettyWriter->SetInput( printableImageFilter->GetOutput() ); + prettyWriter->Update(); + + + return EXIT_SUCCESS; +} + diff --git a/Examples/Projections/CMakeLists.txt b/Examples/Projections/CMakeLists.txt index f09d0e73f34096bdbd155ff7da5482efbb033378..cb57a1f404d92ef9af05e68451d8f512f772620f 100644 --- a/Examples/Projections/CMakeLists.txt +++ b/Examples/Projections/CMakeLists.txt @@ -15,6 +15,9 @@ SET(PROJECTIONS_EXAMPLES ${CXX_TEST_PATH}/otbProjectionsExamplesTests) ADD_EXECUTABLE(SensorModelExample SensorModelExample.cxx ) TARGET_LINK_LIBRARIES(SensorModelExample OTBProjections OTBCommon OTBIO ITKCommon ITKIO) +ADD_EXECUTABLE(MapProjectionExample MapProjectionExample.cxx ) +TARGET_LINK_LIBRARIES(MapProjectionExample OTBProjections OTBCommon OTBIO) + ADD_EXECUTABLE(OrthoRectificationExample OrthoRectificationExample.cxx ) TARGET_LINK_LIBRARIES(OrthoRectificationExample OTBProjections OTBCommon OTBIO ITKCommon ITKIO) diff --git a/Examples/Projections/MapProjectionExample.cxx b/Examples/Projections/MapProjectionExample.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d162c0cf0991f5038b7920ca52fdf0366885c946 --- /dev/null +++ b/Examples/Projections/MapProjectionExample.cxx @@ -0,0 +1,47 @@ +/*========================================================================= + + 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. + +=========================================================================*/ +#if defined(_MSC_VER) +#pragma warning ( disable : 4786 ) +#endif + +#include "otbMapProjections.h" + +int main( int argc, char* argv[] ) +{ + if(argc < 3 ) + { + std::cout << argv[0] <<" <lon> <lat> <outputfile>" << std::endl; + + return EXIT_FAILURE; + } + + double lon = atof(argv[1]); + double lat = atof(argv[2]); + const char * outFileName = argv[3]; + + std::ofstream file; + file.open(outFileName); + file << std::setprecision(15); + + otb::UtmForwardProjection::Pointer lUtmProjection = otb::UtmForwardProjection::New(); + + + + + return EXIT_SUCCESS; +} diff --git a/Testing/Code/IO/CMakeLists.txt b/Testing/Code/IO/CMakeLists.txt index a6ea3311dcb0737f6b50c508d32bd703be499e2e..4a635907a437744e954c900fb015fb40fed478d3 100755 --- a/Testing/Code/IO/CMakeLists.txt +++ b/Testing/Code/IO/CMakeLists.txt @@ -176,7 +176,6 @@ ADD_TEST(ioTuMWImageIOCanReadIMG ${IO_TESTS1} otbMWImageIOTestCanRead ADD_TEST(ioTuMWImageIOCanReadMW ${IO_TESTS1} otbMWImageIOTestCanRead ${BASELINE}/QB_Toulouse_Ortho_PAN.mw) - ADD_TEST(ioTvImageFileReaderMW2TIFIMG ${IO_TESTS1} --compare-image ${TOL} ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif ${TEMP}/ioImageFileReaderMW2TIF.tif @@ -192,7 +191,6 @@ ADD_TEST(ioTvImageFileReaderMW2TIFMW ${IO_TESTS1} ${TEMP}/ioImageFileReaderMW2TIF.tif ) - # CanWrite() ADD_TEST(ioTuMWImageIOCanWrite ${IO_TESTS1} otbMWImageIOTestCanWrite ${TEMP}/QB_Toulouse_Ortho_PAN.mw) @@ -452,6 +450,12 @@ ADD_TEST(ioTuGDALImageIOCanRead_ENVI ${IO_TESTS5} otbGDALImageIOTestCanRead # ${INPUTDATA}/poupees_1canal.c1.hdr ) ${INPUTDATA}/poupees_1canal.c1 ) +ADD_TEST(ioTuGDALImageIOCanRead_PDS1 ${IO_TESTS5} otbGDALImageIOTestCanRead + ${INPUTDATA}/pdsImage1.img ) + +ADD_TEST(ioTuGDALImageIOCanRead_PDS2 ${IO_TESTS5} otbGDALImageIOTestCanRead + ${INPUTDATA}/pdsImage2.img ) + IF(OTB_DATA_USE_LARGEINPUT) ADD_TEST(ioTuGDALImageIOCanRead_RADARSAT ${IO_TESTS5} otbGDALImageIOTestCanRead @@ -648,6 +652,7 @@ ADD_TEST(ioTvImageFileWriterPNG2BSQ ${IO_TESTS8} otbImageFileWriterTest ${INPUTDATA}/cthead1.png ${TEMP}/ioImageFileWriterPNG2BSQ_cthead1.hdr ) + ADD_TEST(ioTvImageFileReaderENVI2PNG ${IO_TESTS8} --compare-image ${TOL} ${INPUTDATA}/cthead1.png ${TEMP}/ioImageFileWriterPNG2BSQ_cthead1_2.png @@ -655,6 +660,19 @@ ADD_TEST(ioTvImageFileReaderENVI2PNG ${IO_TESTS8} ${TEMP}/ioImageFileWriterPNG2BSQ_cthead1.hdr ${TEMP}/ioImageFileWriterPNG2BSQ_cthead1_2.png ) +ADD_TEST(ioTvImageFileReaderPDS2TIFF1 ${IO_TESTS8} + --compare-image ${TOL} ${INPUTDATA}/pdsImage1.img + ${TEMP}/ioTvImageFileReaderPDS2TIFF1.tif + otbImageFileReaderTest + ${INPUTDATA}/pdsImage1.img + ${TEMP}/ioTvImageFileReaderPDS2TIFF1.tif) + +ADD_TEST(ioTvImageFileReaderPDS2TIFF2 ${IO_TESTS8} + --compare-image ${TOL} ${INPUTDATA}/pdsImage2.img + ${TEMP}/ioTvImageFileReaderPDS2TIFF2.tif + otbImageFileReaderTest + ${INPUTDATA}/pdsImage2.img + ${TEMP}/ioTvImageFileReaderPDS2TIFF2.tif) # RGB ADD_TEST(ioTvImageFileWriterRGB_PNG2PNG ${IO_TESTS8}