diff --git a/Code/FeatureExtraction/otbTextureFunctorBase.h b/Code/FeatureExtraction/otbTextureFunctorBase.h index ef95be4506caeddb10ce4c33f960aa8684479638..35b037e9dc800a6727d32e60bb794caf901d1edc 100755 --- a/Code/FeatureExtraction/otbTextureFunctorBase.h +++ b/Code/FeatureExtraction/otbTextureFunctorBase.h @@ -29,9 +29,10 @@ namespace otb namespace Functor { /** \class TextureFunctorBase - * \brief This functor ius the base for all texture functors. + * \brief This functor is the base for all texture functors. * - * It uses a neighborhood and an offset (m_Offset) to compute texture. + * It uses a neighborhood iterator which radius is the one of the considered + * neighborhood plsu an offset (m_Offset) to compute texture. * It computes the mean, standard deviation of the two areas and the joint histogram using * Scott formula for the bins lengths computation. * TIterInput is an iterator, TOutput is a PixelType. @@ -171,17 +172,19 @@ public: outPix.Fill(0); OffsetType offset; offset.Fill(0); + // Compute the neighborhood radius from the neigh+offset iterator to extract the neighborhood area from the iterator RadiusType radius; - radius[0] = 0.5*( itOff.GetSize()[0] - 1 ) - vcl_abs(m_Offset[0]); - radius[1] = 0.5*( itOff.GetSize()[1] - 1 ) - vcl_abs(m_Offset[1]); + radius[0] = static_cast<unsigned int>( 0.5*( static_cast<double>(itOff.GetSize()[0] - 1) ) - static_cast<double>( vcl_abs(m_Offset[0])) ); + radius[1] = static_cast<unsigned int>( 0.5*( static_cast<double>(itOff.GetSize()[1] - 1) ) - static_cast<double>( vcl_abs(m_Offset[1])) ); + // For each channel for ( unsigned int i=0; i<itOff.GetCenterPixel().GetSize(); i++ ) { NeighborhoodType inNeigh; inNeigh.SetRadius(radius); NeighborhoodType offNeigh; offNeigh.SetRadius(radiusOff); - + // Extract the neighborhood area for ( int l = -static_cast<int>(radius[0]); l <= static_cast<int>(radius[0]); l++ ) { offset[0] = l; @@ -191,6 +194,7 @@ public: inNeigh[offset] = itOff.GetPixel(offset)[i]; } } + // Extract the offset area offset.Fill(0); for ( int l = -static_cast<int>(radiusOff[0]); l <= static_cast<int>(radiusOff[0]); l++ ) { diff --git a/Code/FeatureExtraction/otbVarianceTextureFunctor.h b/Code/FeatureExtraction/otbVarianceTextureFunctor.h index 35de4f25e43655e581d69ea4ca8b6da0752b45b2..a3b3578ae99968dedc15253ff356e1d6d47ac23b 100755 --- a/Code/FeatureExtraction/otbVarianceTextureFunctor.h +++ b/Code/FeatureExtraction/otbVarianceTextureFunctor.h @@ -66,7 +66,7 @@ public: for (unsigned s = 0; s<this->GetHisto()[r].size(); s++) { double p = static_cast<double>(this->GetHisto()[r][s]) * areaInv; - double square = vcl_pow( ( ( (static_cast<double>(s)+0.5)*this->GetNeighBinLength() ) - this->GetMean()), 2); + double square = vcl_pow( ( ( (static_cast<double>(s)+0.5)*this->GetNeighBinLength() ) - mean), 2); out += square*p; } } diff --git a/Code/IO/otbImageSeriesFileReader.txx b/Code/IO/otbImageSeriesFileReader.txx index a8ea6344ea161c7d6142fcb76c69a348834c187e..a2511a577c8ef5ac47b7027f1274617675212cce 100644 --- a/Code/IO/otbImageSeriesFileReader.txx +++ b/Code/IO/otbImageSeriesFileReader.txx @@ -171,7 +171,6 @@ ImageSeriesFileReader< TImage > return; } - int numBand = 0; std::vector<int> bands; int aBand,oldBand=-1; char sep; diff --git a/Examples/FeatureExtraction/CMakeLists.txt b/Examples/FeatureExtraction/CMakeLists.txt index a8a13169ea9909b749450dc20d172729df284fd7..1ea4ff540f555f4ed5f41905928685af84c5ce96 100644 --- a/Examples/FeatureExtraction/CMakeLists.txt +++ b/Examples/FeatureExtraction/CMakeLists.txt @@ -301,10 +301,12 @@ ADD_TEST(ScaleInvariantFeatureImageFilterTest ${EXE_TESTS2} ADD_TEST(CloudDetectionExampleTest ${EXE_TESTS2} --compare-image ${TOL} ${BASELINE}/CloudDetectionOutput.png - ${TEMP}/CloudDetectionOutput.png + ${TEMP}/PrettyCloudDetectionOutput.png CloudDetectionExampleTest ${INPUTDATA}/CloudsOnReunion.tif - ${TEMP}/CloudDetectionOutput.png + ${TEMP}/CloudDetectionOutput.tif + ${TEMP}/PrettyCloudDetectionInput.png + ${TEMP}/PrettyCloudDetectionOutput.png 553 467 734 581 0.4 0.6 1.0 ) diff --git a/Examples/FeatureExtraction/CloudDetectionExample.cxx b/Examples/FeatureExtraction/CloudDetectionExample.cxx index 1c4296563da5028096f19cba5599d8ad5b958dbb..40f1645fdce0c965f5ba781bed8485aed25443e0 100644 --- a/Examples/FeatureExtraction/CloudDetectionExample.cxx +++ b/Examples/FeatureExtraction/CloudDetectionExample.cxx @@ -25,7 +25,7 @@ // Software Guide : BeginCommandLineArgs // INPUT: {CloudsOnReunion.tif} -// OUTPUT: {CloudDetectionOutput.png} +// OUTPUT: {CloudDetectionOutput.tif} , {pretty_CloudsOnReunion.png} , {pretty_CloudDetectionOutput.png} // 553 467 734 581 0.4 0.6 1.0 // Software Guide : EndCommandLineArgs @@ -52,19 +52,22 @@ // Software Guide : EndCodeSnippet +#include "itkExceptionObject.h" #include "otbImage.h" #include "otbVectorImage.h" #include "otbImageFileReader.h" #include "otbImageFileWriter.h" -#include "itkExceptionObject.h" +#include "itkRescaleIntensityImageFilter.h" +#include "otbVectorRescaleIntensityImageFilter.h" +#include "otbMultiChannelExtractROI.h" int main( int argc, char * argv[] ) { - if (argc != 10) + if (argc != 12) { std::cerr << "Usage: "<< argv[0]; - std::cerr << "inputFileName outputFileName "; + std::cerr << "inputFileName outputFileName printableInputFileName printableOutputFileName"; std::cerr << "firstPixelComponent secondPixelComponent thirdPixelComponent fourthPixelComponent "; std::cerr << "variance "; std::cerr << "minThreshold maxThreshold "<<std::endl; @@ -83,7 +86,7 @@ int main( int argc, char * argv[] ) // Software Guide : BeginCodeSnippet typedef double InputPixelType; - typedef unsigned short OutputPixelType; + typedef double OutputPixelType; // Software Guide : EndCodeSnippet @@ -96,9 +99,9 @@ int main( int argc, char * argv[] ) // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - typedef otb::VectorImage<InputPixelType,Dimension> VectorImageType; - typedef VectorImageType::PixelType VectorPixelType; - typedef otb::Image<OutputPixelType,Dimension> OutputImageType; + typedef otb::VectorImage<InputPixelType,Dimension> VectorImageType; + typedef VectorImageType::PixelType VectorPixelType; + typedef otb::Image<OutputPixelType,Dimension> OutputImageType; // Software Guide : EndCodeSnippet @@ -111,7 +114,7 @@ int main( int argc, char * argv[] ) // Software Guide : BeginCodeSnippet - typedef otb::Functor::CloudDetectionFunctor<VectorPixelType,InputPixelType > FunctorType; + typedef otb::Functor::CloudDetectionFunctor<VectorPixelType, OutputPixelType> FunctorType; // Software Guide : EndCodeSnippet @@ -124,7 +127,7 @@ int main( int argc, char * argv[] ) // Software Guide : BeginCodeSnippet - typedef otb::CloudDetectionFilter<VectorImageType,OutputImageType,FunctorType > CloudDetectionFilterType; + typedef otb::CloudDetectionFilter<VectorImageType, OutputImageType, FunctorType> CloudDetectionFilterType; // Software Guide : EndCodeSnippet @@ -175,10 +178,10 @@ int main( int argc, char * argv[] ) VectorPixelType referencePixel; referencePixel.SetSize(4); referencePixel.Fill(0.); - referencePixel[0] = (atof(argv[3])); - referencePixel[1] = (atof(argv[4])); - referencePixel[2] = (atof(argv[5])); - referencePixel[3] = (atof(argv[6])); + referencePixel[0] = (atof(argv[5])); + referencePixel[1] = (atof(argv[6])); + referencePixel[2] = (atof(argv[7])); + referencePixel[3] = (atof(argv[8])); cloudDetection->SetReferencePixel(referencePixel); // Software Guide : EndCodeSnippet @@ -192,7 +195,7 @@ int main( int argc, char * argv[] ) // Software Guide : BeginCodeSnippet - cloudDetection->SetVariance(atof(argv[7])); + cloudDetection->SetVariance(atof(argv[9])); // Software Guide : EndCodeSnippet @@ -205,8 +208,8 @@ int main( int argc, char * argv[] ) // Software Guide : BeginCodeSnippet - cloudDetection->SetMinThreshold(atof(argv[8])); - cloudDetection->SetMaxThreshold(atof(argv[9])); + cloudDetection->SetMinThreshold(atof(argv[10])); + cloudDetection->SetMaxThreshold(atof(argv[11])); // Software Guide : EndCodeSnippet @@ -224,8 +227,8 @@ int main( int argc, char * argv[] ) // the cloud detection filter to a cloudy image. // \begin{figure} // \center - // \includegraphics[width=0.44\textwidth]{CloudsOnReunion.eps} - // \includegraphics[width=0.44\textwidth]{CloudDetectionOutput.eps} + // \includegraphics[width=0.44\textwidth]{pretty_CloudsOnReunion.eps} + // \includegraphics[width=0.44\textwidth]{pretty_CloudDetectionOutput.eps} // From left to right : original image, mask cloud resulting from processing.} // \label{fig:CLOUDDETECTION_FILTER} // \end{figure} @@ -233,6 +236,45 @@ int main( int argc, char * argv[] ) // Software Guide : EndLatex + // Pretty image creation for printing + typedef otb::Image<unsigned char, Dimension> OutputPrettyImageType; + typedef otb::VectorImage<unsigned char, Dimension> InputPrettyImageType; + typedef otb::ImageFileWriter<OutputPrettyImageType> WriterPrettyOutputType; + typedef otb::ImageFileWriter<InputPrettyImageType> WriterPrettyInputType; + typedef itk::RescaleIntensityImageFilter< OutputImageType, OutputPrettyImageType> RescalerOutputType; + typedef otb::VectorRescaleIntensityImageFilter< VectorImageType, InputPrettyImageType> RescalerInputType; + typedef otb::MultiChannelExtractROI<InputPixelType, InputPixelType> ChannelExtractorType; + + ChannelExtractorType::Pointer selecter = ChannelExtractorType::New(); + RescalerInputType::Pointer inputRescaler = RescalerInputType::New(); + WriterPrettyInputType::Pointer prettyInputWriter = WriterPrettyInputType::New(); + selecter->SetInput( reader->GetOutput()); + selecter->SetChannel(3); + selecter->SetChannel(2); + selecter->SetChannel(1); + inputRescaler->SetInput( selecter->GetOutput() ); + VectorPixelType minimum, maximum; + minimum.SetSize( 3 ); + maximum.SetSize( 3 ); + minimum.Fill(0); + maximum.Fill(255); + inputRescaler->SetOutputMinimum(minimum); + inputRescaler->SetOutputMaximum(maximum); + prettyInputWriter->SetFileName( argv[3] ); + prettyInputWriter->SetInput( inputRescaler->GetOutput() ); + + + RescalerOutputType::Pointer outputRescaler = RescalerOutputType::New(); + WriterPrettyOutputType::Pointer prettyOutputWriter = WriterPrettyOutputType::New(); + outputRescaler->SetInput( cloudDetection->GetOutput() ); + outputRescaler->SetOutputMinimum(0); + outputRescaler->SetOutputMaximum(255); + prettyOutputWriter->SetFileName( argv[4] ); + prettyOutputWriter->SetInput( outputRescaler->GetOutput() ); + + prettyInputWriter->Update(); + prettyOutputWriter->Update(); + return EXIT_SUCCESS; } diff --git a/Testing/Code/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt index d3971bdfb30bc31be30d10887e995b12e4e146b9..5d7027ece312ba4da90215131fc7276d87724af0 100644 --- a/Testing/Code/FeatureExtraction/CMakeLists.txt +++ b/Testing/Code/FeatureExtraction/CMakeLists.txt @@ -1060,11 +1060,11 @@ ADD_TEST(feTuLineSegmentDetectorNew ${FEATUREEXTRACTION_TESTS11} ADD_TEST(feTvLineSegmentDetector ${FEATUREEXTRACTION_TESTS11} --compare-image ${EPS} - ${BASELINE}/feTvLineSegmentdetectorOutputImage.tif - ${TEMP}/feTvLineSegmentdetectorOutputImage.tif + ${BASELINE}/feTvLineSegmentDetectorOutputImage.tif + ${TEMP}/feTvLineSegmentDetectorOutputImage.tif otbLineSegmentDetector ${INPUTDATA}/scene.png #prison_toulouse.tif - ${TEMP}/feTvLineSegmentdetectorOutputImage.tif + ${TEMP}/feTvLineSegmentDetectorOutputImage.tif ) # ------- otb::LineSpatialObjectListToRightAnglePointSetFilter ------------- diff --git a/Testing/Code/Visu/CMakeLists.txt b/Testing/Code/Visu/CMakeLists.txt index 96a89e462c114ff0e8d5134ef8b571f23bcd1143..75286de6050efc29b87f72e8dda63c732c84e0b7 100644 --- a/Testing/Code/Visu/CMakeLists.txt +++ b/Testing/Code/Visu/CMakeLists.txt @@ -207,7 +207,6 @@ otbImageToGrayscaleAnaglyphImageFilterNew.cxx otbImageToGrayscaleAnaglyphImageFilter.cxx otbVectorImageToColorAnaglyphVectorImageFilterNew.cxx otbVectorImageToColorAnaglyphVectorImageFilter.cxx -otbAlternateViewerTest.cxx otbImageWidgetPolygonFormNew.cxx otbImageWidgetPolygonForm.cxx otbHistogramAndTransferFunctionWidgetNew.cxx diff --git a/Testing/Code/Visu/otbAlternateViewerTest.cxx b/Testing/Code/Visu/otbAlternateViewerTest.cxx deleted file mode 100644 index c7a66225b346f9f20a9621bf5dba3615558f4cb0..0000000000000000000000000000000000000000 --- a/Testing/Code/Visu/otbAlternateViewerTest.cxx +++ /dev/null @@ -1,82 +0,0 @@ -/*========================================================================= - -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. - -=========================================================================*/ - -#include "otbVectorImage.h" -#include "otbVectorRescaleIntensityImageFilter.h" -#include "otbImageFileReader.h" -#include "otbImageAlternateViewer.h" -#include "Fl/Fl.H" - - -int otbAlternateViewerTest(int argc, char* argv[]) -{ - const unsigned int Dimension = 2; - typedef double PixelType; - typedef otb::VectorImage<PixelType,Dimension> ImageType; - typedef otb::ImageFileReader<ImageType> ReaderType; - typedef otb::ImageAlternateViewer<PixelType> ViewerType; - - ReaderType::Pointer reader = ReaderType::New(); - reader->SetFileName(argv[1]); - reader->GenerateOutputInformation(); - - ReaderType::Pointer reader2 = ReaderType::New(); - reader2->SetFileName(argv[2]); - reader2->GenerateOutputInformation(); - - ImageType::PixelType min,max; - min.SetSize(reader->GetOutput()->GetNumberOfComponentsPerPixel()); - max.SetSize(reader->GetOutput()->GetNumberOfComponentsPerPixel()); - // min[0]=195; - // min[1]=241; - // min[2]=127; - // min[3]=130; - // max[0]=387; - // max[1]=602; - // max[2]=469; - // max[3]=740; - min.Fill(0); - max.Fill(255); - - // RescalerType::Pointer rescaler = RescalerType::New(); - // rescaler->SetOutputMinimum(min); - // rescaler->SetOutputMaximum(max); - // rescaler->SetInput(reader->GetOutput()); - // rescaler->SetClampThreshold(atof(argv[2])); - // rescaler->GenerateOutputInformation(); - - Fl_Window window(512,512); - ViewerType::Pointer viewer = ViewerType::New(); - viewer->SetImage(reader->GetOutput()); - viewer->SetSecondImage(reader2->GetOutput()); - viewer->SetMinComponentValues(min); - viewer->SetMaxComponentValues(max); - viewer->SetRedChannelIndex(atoi(argv[3])); - viewer->SetGreenChannelIndex(atoi(argv[4])); - viewer->SetBlueChannelIndex(atoi(argv[5])); - window.end(); - window.resizable(viewer.GetPointer()); - viewer->Init(0,0,512,512,"test de la nouvelle visu"); - window.show(); - viewer->Show(); - - Fl::check(); - // Fl::run(); - - return EXIT_SUCCESS; -} diff --git a/Testing/Code/Visu/otbVisuTests2.cxx b/Testing/Code/Visu/otbVisuTests2.cxx index 70f276c50726fe325f1cafa1d5105a80aed95dd6..cd73914c804c52e46575afca9299878945c618c6 100644 --- a/Testing/Code/Visu/otbVisuTests2.cxx +++ b/Testing/Code/Visu/otbVisuTests2.cxx @@ -26,18 +26,17 @@ void RegisterTests() { - REGISTER_TEST(otbImageViewerWithMultiBandFilter); - REGISTER_TEST(otbDoubleImageViewerWithLink); - REGISTER_TEST(otbImageToGrayscaleAnaglyphImageFilterNew); - REGISTER_TEST(otbImageToGrayscaleAnaglyphImageFilter); - REGISTER_TEST(otbVectorImageToColorAnaglyphVectorImageFilterNew); - REGISTER_TEST(otbVectorImageToColorAnaglyphVectorImageFilter); - REGISTER_TEST(otbAlternateViewerTest); - REGISTER_TEST(otbImageWidgetPolygonFormNew); - REGISTER_TEST(otbImageWidgetPolygonForm); - REGISTER_TEST(otbHistogramAndTransferFunctionWidgetNew); - REGISTER_TEST(otbHistogramAndTransferFunctionWidget); - REGISTER_TEST(otbImageWidgetTransferFunctionsNew); - REGISTER_TEST(otbImageWidgetTransferFunctions); - REGISTER_TEST(otbImageViewerWithOverlay); +REGISTER_TEST(otbImageViewerWithMultiBandFilter); +REGISTER_TEST(otbDoubleImageViewerWithLink); +REGISTER_TEST(otbImageToGrayscaleAnaglyphImageFilterNew); +REGISTER_TEST(otbImageToGrayscaleAnaglyphImageFilter); +REGISTER_TEST(otbVectorImageToColorAnaglyphVectorImageFilterNew); +REGISTER_TEST(otbVectorImageToColorAnaglyphVectorImageFilter); +REGISTER_TEST(otbImageWidgetPolygonFormNew); +REGISTER_TEST(otbImageWidgetPolygonForm); +REGISTER_TEST(otbHistogramAndTransferFunctionWidgetNew); +REGISTER_TEST(otbHistogramAndTransferFunctionWidget); +REGISTER_TEST(otbImageWidgetTransferFunctionsNew); +REGISTER_TEST(otbImageWidgetTransferFunctions); +REGISTER_TEST(otbImageViewerWithOverlay); }