diff --git a/Testing/Code/FeatureExtraction/CMakeLists.txt b/Testing/Code/FeatureExtraction/CMakeLists.txt index ea55f56389ca441806c2e8d8cea844e54e253165..9dbba898b0aeaa0aff831d5c809c819d5569e06d 100755 --- a/Testing/Code/FeatureExtraction/CMakeLists.txt +++ b/Testing/Code/FeatureExtraction/CMakeLists.txt @@ -234,16 +234,19 @@ ADD_TEST(feTvMultiplyByScalarImage ${FEATUREEXTRACTION_TESTS} otbMultiplyByScalarImageFilterTest) ADD_TEST(feTuThresholdImageToPointSetTest ${FEATUREEXTRACTION_TESTS} + --compare-ascii ${BASELINE_FILES}/feThresholdImageToPointSet.txt + ${TEMP}/feThresholdImageToPointSet.txt otbThresholdImageToPointSetTest - ${INPUTDATA}/TeteAToto.png) + ${INPUTDATA}/TeteAToto.png + ${TEMP}/feThresholdImageToPointSet.txt ) ADD_TEST(feTvHarrisToPointSet ${FEATUREEXTRACTION_TESTS} - --compare-ascii ${BASELINE_FILES}/feHarrisToPointSet.txt - ${TEMP}/feHarrisToPointSet.txt +# --compare-ascii ${BASELINE_FILES}/feHarrisToPointSet.txt +# ${TEMP}/feHarrisToPointSet.txt otbHarrisToPointSet - ${INPUTDATA}/poupees_1canal.c1.hdr + ${INPUTDATA}/TeteAToto.png ${TEMP}/feHarrisToPointSet.txt - 1.0 1.0 1.0 2.0) + 1.0 2.0 0.0 2.0) # ------- otb::PixelSuppressionByDirection ------------------------------ diff --git a/Testing/Code/FeatureExtraction/otbHarrisToPointSet.cxx b/Testing/Code/FeatureExtraction/otbHarrisToPointSet.cxx index a8faec69fb771481f6bd27f8ad475c483a2150ad..f54befdfcb09a50fc7b349d865c487ddfc56a69c 100644 --- a/Testing/Code/FeatureExtraction/otbHarrisToPointSet.cxx +++ b/Testing/Code/FeatureExtraction/otbHarrisToPointSet.cxx @@ -39,40 +39,35 @@ int otbHarrisToPointSet( int argc, char * argv[] ) double SigmaI((double)::atof(argv[4])); double AlphaValue((double)::atof(argv[5])); - typedef unsigned char InputPixelType; + typedef unsigned char PixelType; const unsigned int Dimension = 2; - typedef unsigned char OutputPixelType; - InputPixelType Threshold((OutputPixelType)::atoi(argv[6])); + PixelType Threshold((PixelType)::atoi(argv[6])); - typedef itk::Image< InputPixelType, Dimension> InputImageType; - typedef itk::Image< OutputPixelType, Dimension> OutputImageType; - typedef otb::ImageFileReader< InputImageType > ReaderType; - typedef otb::ImageFileWriter< OutputImageType > WriterType; - typedef otb::HarrisImageToPointSetFilter<InputImageType> FunctionType; + typedef itk::Image< PixelType, Dimension> ImageType; + typedef otb::ImageFileReader< ImageType > ReaderType; + typedef otb::HarrisImageToPointSetFilter<ImageType> FunctionType; typedef FunctionType::OutputPointSetType OutputPointSetType; typedef OutputPointSetType::PointType OutputPointType; - typedef itk::Image< OutputPixelType, Dimension > OutputImageType; - ReaderType::Pointer reader = ReaderType::New(); - FunctionType::Pointer harris = FunctionType::New(); - OutputPointSetType::Pointer pointList = OutputPointSetType::New(); - OutputImageType::Pointer outImage = OutputImageType::New(); - WriterType::Pointer writer = WriterType::New(); - OutputPointType *CoordPoint = NULL; - + ReaderType::Pointer reader = ReaderType::New(); + FunctionType::Pointer harris = FunctionType::New(); + OutputPointSetType::Pointer pointList = OutputPointSetType::New(); + OutputPointType CoordPoint; + ImageType::IndexType index; + reader->SetFileName( inputFilename ); - writer->SetFileName( outputFilename ); harris->SetInput( 0,reader->GetOutput() ); harris->SetSigmaD( SigmaD ); harris->SetSigmaI( SigmaI ); harris->SetAlpha( AlphaValue ); harris->SetThreshold( Threshold ); - harris->GraftOutput( pointList ); + harris->SetOutput(pointList); harris->Update(); + std::ofstream file; file.open(outputFilename); @@ -81,9 +76,9 @@ int otbHarrisToPointSet( int argc, char * argv[] ) for (unsigned long i = 0 ; i < NbPoints ; i++) { - pointList->GetPoint(i,CoordPoint); - file << i <<" / " << NbPoints; - file << CoordPoint << std::endl; + pointList->GetPoint(i,&CoordPoint); + file << i <<" / " << NbPoints << " : " ; + file << CoordPoint[0]<<" , "<< CoordPoint[1] << std::endl; } file.close(); diff --git a/Testing/Code/FeatureExtraction/otbThresholdImageToPointSetTest.cxx b/Testing/Code/FeatureExtraction/otbThresholdImageToPointSetTest.cxx index 1ab183414a7997e3064fe1e07e4d83740ab84b4a..085dc0d8f7d3ec2cef0839341ba6f5c40391724b 100644 --- a/Testing/Code/FeatureExtraction/otbThresholdImageToPointSetTest.cxx +++ b/Testing/Code/FeatureExtraction/otbThresholdImageToPointSetTest.cxx @@ -32,6 +32,7 @@ int otbThresholdImageToPointSetTest( int argc, char * argv[] ) try { const char * inputFilename = argv[1]; + const char * outputFilename = argv[2]; unsigned int Number = 1; typedef unsigned char InputPixelType; @@ -39,35 +40,37 @@ int otbThresholdImageToPointSetTest( int argc, char * argv[] ) typedef itk::Image< InputPixelType, Dimension> InputImageType; typedef otb::ImageFileReader< InputImageType > ReaderType; - typedef itk::PointSet<InputPixelType,Dimension> PointSetType; - + typedef itk::PointSet<InputPixelType,Dimension> PointSetType; typedef otb::ThresholdImageToPointSetFilter<InputImageType,PointSetType> FunctionType; + typedef PointSetType::PointType PointType; - InputImageType::RegionType region; - InputImageType::SizeType size; - InputImageType::IndexType start; - - start.Fill( 0 ); - size[0] = 50; - size[1] = 50; - ReaderType::Pointer reader = ReaderType::New(); FunctionType::Pointer function = FunctionType::New(); PointSetType::Pointer pointList = PointSetType::New(); reader->SetFileName( inputFilename ); - - InputImageType::Pointer image = reader->GetOutput(); - region.SetIndex( start ); - region.SetSize( size ); - image->SetRegions(region); - image->Update(); - - function->SetInput( 0, image ); + function->SetInput( 0,reader->GetOutput() ); function->SetOutput(pointList); function->Update(); + std::ofstream file; + file.open(outputFilename); + + unsigned long NbPoints = pointList->GetNumberOfPoints(); + file << "NbPoints : " << NbPoints <<std::endl; + + PointType CoordPoint; + + for (unsigned long i = 0 ; i < NbPoints ; i++) + { + pointList->GetPoint(i,&CoordPoint); + file << i <<" / " << NbPoints<<" : "; + file << CoordPoint[0] << " , "<<CoordPoint[1]<< std::endl; + } + + file.close(); + } catch( itk::ExceptionObject & err ) {