<commit_before>/*=========================================================================

  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 "itkFixedArray.h"
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbFineCorrelationImageFilter.h"
#include "otbStandardFilterWatcher.h"
#include "itkTimeProbe.h"

int otbFineCorrelationImageFilterTest( int argc, char * argv[] )
{
  if(argc!=9)
    {
    std::cerr<<"Usage: "<<argv[0]<<" fixed_fname moving_fname output_correl output_field radius search_radius refineMethod subpixPrecision"<<std::endl;
    return EXIT_FAILURE;
    }
  const char * fixedFileName  = argv[1];
  const char * movingFileName = argv[2];
  const char * correlFileName = argv[3];
  const char * fieldFileName  = argv[4];
  const unsigned int radius   = atoi(argv[5]);
  const unsigned int sradius  = atoi(argv[6]);
  const int          refine   = atoi(argv[7]);
  const unsigned int precision = atoi(argv[8]);

  typedef double      PixelType;
  const unsigned int  Dimension = 2;

  typedef itk::FixedArray<PixelType,Dimension>                                DeformationValueType;
  typedef otb::Image< PixelType,  Dimension >                                 ImageType;
  typedef otb::Image<DeformationValueType,Dimension>                          FieldImageType;
  typedef otb::ImageFileReader< ImageType >                                   ReaderType;
  typedef otb::ImageFileWriter< ImageType >                                   CorrelWriterType;
  typedef otb::ImageFileWriter< FieldImageType>                               FieldWriterType;
  typedef otb::FineCorrelationImageFilter<ImageType,ImageType,FieldImageType> CorrelationFilterType;
  
  ReaderType::Pointer freader = ReaderType::New();
  freader->SetFileName(fixedFileName);
  //freader->Update();
  
  ReaderType::Pointer mreader = ReaderType::New();
  mreader->SetFileName(movingFileName);
  //mreader->Update();

  CorrelationFilterType::Pointer correlation = CorrelationFilterType::New();
  correlation->SetFixedInput(freader->GetOutput());
  correlation->SetMovingInput(mreader->GetOutput());
  correlation->SetRadius(radius);
  correlation->SetSearchRadius(sradius);
  if(refine == 0)
    {
    correlation->SetRefinementModeToCoarse();
    }
  else if(refine == 1)
    {
    correlation->SetRefinementModeToLSQRQuadFit();
    }
  else
    {
    correlation->SetRefinementModeToSubPixel();
    }

  correlation->SetSubPixelPrecision(precision);
  correlation->SetNumberOfThreads(1);
  //  otb::StandardFilterWatcher watcher(correlation,"Correlation");
  itk::TimeProbe chrono;
  chrono.Start();
  correlation->Update();
  chrono.Stop();
  std::cout<<chrono.GetMeanTime()<<"\t";

  CorrelWriterType::Pointer correlWriter = CorrelWriterType::New();
  correlWriter->SetFileName(correlFileName);
  correlWriter->SetInput(correlation->GetOutput());
  correlWriter->Update();

  FieldWriterType::Pointer fieldWriter = FieldWriterType::New();
  fieldWriter->SetFileName(fieldFileName);
  fieldWriter->SetInput(correlation->GetOutputDeformationField());
  fieldWriter->Update();

  return EXIT_SUCCESS;
}
<commit_msg>ENH: Multi-threading should not be disabled in test<commit_after>/*=========================================================================

  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 "itkFixedArray.h"
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbFineCorrelationImageFilter.h"
#include "otbStandardFilterWatcher.h"
#include "itkTimeProbe.h"

int otbFineCorrelationImageFilterTest( int argc, char * argv[] )
{
  if(argc!=9)
    {
    std::cerr<<"Usage: "<<argv[0]<<" fixed_fname moving_fname output_correl output_field radius search_radius refineMethod subpixPrecision"<<std::endl;
    return EXIT_FAILURE;
    }
  const char * fixedFileName  = argv[1];
  const char * movingFileName = argv[2];
  const char * correlFileName = argv[3];
  const char * fieldFileName  = argv[4];
  const unsigned int radius   = atoi(argv[5]);
  const unsigned int sradius  = atoi(argv[6]);
  const int          refine   = atoi(argv[7]);
  const unsigned int precision = atoi(argv[8]);

  typedef double      PixelType;
  const unsigned int  Dimension = 2;

  typedef itk::FixedArray<PixelType,Dimension>                                DeformationValueType;
  typedef otb::Image< PixelType,  Dimension >                                 ImageType;
  typedef otb::Image<DeformationValueType,Dimension>                          FieldImageType;
  typedef otb::ImageFileReader< ImageType >                                   ReaderType;
  typedef otb::ImageFileWriter< ImageType >                                   CorrelWriterType;
  typedef otb::ImageFileWriter< FieldImageType>                               FieldWriterType;
  typedef otb::FineCorrelationImageFilter<ImageType,ImageType,FieldImageType> CorrelationFilterType;
  
  ReaderType::Pointer freader = ReaderType::New();
  freader->SetFileName(fixedFileName);
  //freader->Update();
  
  ReaderType::Pointer mreader = ReaderType::New();
  mreader->SetFileName(movingFileName);
  //mreader->Update();

  CorrelationFilterType::Pointer correlation = CorrelationFilterType::New();
  correlation->SetFixedInput(freader->GetOutput());
  correlation->SetMovingInput(mreader->GetOutput());
  correlation->SetRadius(radius);
  correlation->SetSearchRadius(sradius);
  if(refine == 0)
    {
    correlation->SetRefinementModeToCoarse();
    }
  else if(refine == 1)
    {
    correlation->SetRefinementModeToLSQRQuadFit();
    }
  else
    {
    correlation->SetRefinementModeToSubPixel();
    }

  correlation->SetSubPixelPrecision(precision);
  //  otb::StandardFilterWatcher watcher(correlation,"Correlation");
  itk::TimeProbe chrono;
  chrono.Start();
  correlation->Update();
  chrono.Stop();
  std::cout<<chrono.GetMeanTime()<<"\t";

  CorrelWriterType::Pointer correlWriter = CorrelWriterType::New();
  correlWriter->SetFileName(correlFileName);
  correlWriter->SetInput(correlation->GetOutput());
  correlWriter->Update();

  FieldWriterType::Pointer fieldWriter = FieldWriterType::New();
  fieldWriter->SetFileName(fieldFileName);
  fieldWriter->SetInput(correlation->GetOutputDeformationField());
  fieldWriter->Update();

  return EXIT_SUCCESS;
}

{'fraction_non_alphanumeric': 0.1471311475409836, 'fraction_numerical': 0.0047814207650273225, 'mean_word_length': 4.080499653018737, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 64, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3523375', 'n_tokens_mistral': 2135, 'n_tokens_neox': 2036, 'n_words': 426}