diff --git a/Code/Testing/otbTestMain.h b/Code/Testing/otbTestMain.h index 8daee5c11cf94b61c5a6afa38efbaea79e8e2acf..4b4dd7e35e514b0d8442c7bc5b210ffae04a5a20 100644 --- a/Code/Testing/otbTestMain.h +++ b/Code/Testing/otbTestMain.h @@ -56,8 +56,8 @@ void PrintAvailableTests() void LoadTestEnv() { //Set seed for rand and itk mersenne twister - srand(1); - itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->SetSeed(1234); + //srand(1); + //itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->SetSeed(1234); } int main(int ac, char* av[]) diff --git a/Testing/Fa/0000433-LineSegmentDetector_8b_16b_compare.cxx b/Testing/Fa/0000433-LineSegmentDetector_8b_16b_compare.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b2f7411626a23b1f158f8a2f94d952a4b338ca8d --- /dev/null +++ b/Testing/Fa/0000433-LineSegmentDetector_8b_16b_compare.cxx @@ -0,0 +1,88 @@ +/*========================================================================= + + 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 "otbImage.h" +#include "otbLineSegmentDetector.h" + +#include "otbImageFileReader.h" +#include "otbVectorDataFileWriter.h" +#include "otbImageFileWriter.h" + +// Code showing difference between LSD with 8 and 16 bits images. +// http://bugs.orfeo-toolbox.org/view.php?id=433 + +int main(int argc, char *argv[]) +{ + if (argc != 6) + { + std::cout << "Usage : <inputImage_8b> <inputImage_16b> <outputImage_8b> <outputImage_16b>" << std::endl; + + return EXIT_FAILURE; + } + + const char * infname8 = argv[2]; + const char * infname16 = argv[3]; + const char * outfname8 = argv[4]; + const char * outfname16 = argv[5]; + + /** Typedefs */ + typedef unsigned char PixelType8; + typedef otb::Image<PixelType8> ImageType8; + typedef otb::ImageFileReader<ImageType8> ReaderType8; + typedef otb::LineSegmentDetector<ImageType8, double> LSDFilterType8; + typedef otb::ImageFileWriter<ImageType8> WriterType8; + + typedef unsigned short PixelType16; + typedef otb::Image<PixelType16> ImageType16; + typedef otb::ImageFileReader<ImageType16> ReaderType16; + typedef otb::LineSegmentDetector<ImageType16, double> LSDFilterType16; + typedef otb::ImageFileWriter<ImageType16> WriterType16; + + typedef LSDFilterType8::VectorDataType VectorDataType; + typedef otb::VectorDataFileWriter<VectorDataType> VectorDataWriterType; + + /** 8bits */ + //Instantiation of smart pointer + ReaderType8::Pointer reader8 = ReaderType8::New(); + LSDFilterType8::Pointer lsdFilter8 = LSDFilterType8::New(); + //Reade the input image + reader8->SetFileName(infname8); + reader8->GenerateOutputInformation(); + //LSD Detection + lsdFilter8->SetInput(reader8->GetOutput()); + VectorDataWriterType::Pointer vdWriter8 = VectorDataWriterType::New(); + vdWriter8->SetFileName(outfname8); + vdWriter8->SetInput(lsdFilter8->GetOutput()); + vdWriter8->Update(); + + /** 16bits */ + //Instantiation of smart pointer + ReaderType16::Pointer reader16 = ReaderType16::New(); + LSDFilterType16::Pointer lsdFilter16 = LSDFilterType16::New(); + //Reade the input image + reader16->SetFileName(infname16); + reader16->GenerateOutputInformation(); + //LSD Detection + lsdFilter16->SetInput(reader16->GetOutput()); + VectorDataWriterType::Pointer vdWriter16 = VectorDataWriterType::New(); + vdWriter16->SetFileName(outfname16); + vdWriter16->SetInput(lsdFilter16->GetOutput()); + vdWriter16->Update(); + + return EXIT_SUCCESS; +} diff --git a/Testing/Fa/CMakeLists.txt b/Testing/Fa/CMakeLists.txt index d91de96303dc9352bbaf261f995c578ae2d8957b..b7730b2a3c825ef2e653c9499959be9f593a8cf4 100644 --- a/Testing/Fa/CMakeLists.txt +++ b/Testing/Fa/CMakeLists.txt @@ -277,6 +277,20 @@ ADD_TEST(FA-000209-SVMValidationLinearlySeparableWithoutProbEstimate_OK ${CXX_TE ADD_TEST(FA-000209-SVMValidationLinearlySeparableWithProbEstimate_KO ${CXX_TEST_PATH}/0000209-SVMValidationLinearlySeparableProbEstimation 0000209-SVMValidationLinearlySeparableProbEstimation 500 500 0.0025 0.0075 0.0075 0.0025 0. 0.0025 0. 0.0025 0 1) + +# ------- FA 0000433 : LSD 8bots vs 16bits ------------------------- +ADD_TEST(FA-0000433-LineSegmentDetector_8b_16b_compare ${CXX_TEST_PATH}/0000433-LineSegmentDetector_8b_16b_compare +#--compare-ogr ${EPSILON_8} +# ${TEMP}/FA-0000433-LSD_8b.shp +# ${TEMP}/FA-0000433-LSD_16b.shp +0000433-LineSegmentDetector_8b_16b_compare + ${INPUTDATA}/scene_8.tif + ${INPUTDATA}/scene_16.tif + ${TEMP}/FA-0000433-LSD_8b.shp + ${TEMP}/FA-0000433-LSD_16b.shp) + + + # ------- Vectorization issue ----------------------------------- # FIXME Desactivated until http://bugs.orfeo-toolbox.org/view.php?id=94 # has somebody working on it @@ -330,4 +344,7 @@ TARGET_LINK_LIBRARIES(0000307-ExtractROICompareRegion OTBIO OTBCommon) ADD_EXECUTABLE(0000428-CastImageFilterStreaming 0000428-CastImageFilterStreaming.cxx) TARGET_LINK_LIBRARIES(0000428-CastImageFilterStreaming OTBIO OTBCommon OTBBasicFilters) +ADD_EXECUTABLE(0000433-LineSegmentDetector_8b_16b_compare 0000433-LineSegmentDetector_8b_16b_compare.cxx) +TARGET_LINK_LIBRARIES(0000433-LineSegmentDetector_8b_16b_compare OTBIO OTBFeatureExtraction) + ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING )