<commit_before>#include "rtkTest.h"
#include "rtkMacro.h"
#include "rtkLUTbasedVariableI0RawToAttImageFilter.h"
#include <itkTimeProbe.h>
#include <itkImageRegionIterator.h>

/**
 * \file rtklutbasedvarI0rawtoatttest.cxx
 *
 * \brief Test rtk::LUTbasedVariableI0RawToAttImageFilter
 *
 * \author <NAME>
 */

typedef itk::Image<unsigned short, 2> ShortImageType;
typedef itk::Image<float, 2> FloatImageType;

void fillImageWithRawData(ShortImageType::Pointer image, unsigned short imageId)
{
  itk::ImageRegionIterator<ShortImageType> it(image, image->GetLargestPossibleRegion());
  it.GoToBegin();
  while (!it.IsAtEnd()){
    it.Set(imageId);
  }
}

int main(int, char** )
{
  itk::TimeProbe clock;

  typedef rtk::LUTbasedVariableI0RawToAttImageFilter ConvertFilterType;
  ConvertFilterType::Pointer convert = ConvertFilterType::New();
  
  // Constant image sources
  ShortImageType::SizeType size;
  size[0] = 2;
  size[1] = 2;
  size[2] = 1;
  ShortImageType::IndexType start;
  start.Fill(0);
  ShortImageType::RegionType region;
  region.SetIndex(start);
  region.SetSize(size);
  ShortImageType::SpacingType spacings;
  spacings[0] = 1.0;
  spacings[1] = 1.0;
  spacings[2] = 1.0;

  ShortImageType::Pointer rawImage = ShortImageType::New();
  rawImage->SetRegions(region);
  rawImage->SetSpacing(spacings);
  rawImage->Allocate();

  convert->SetInput(rawImage);

  for (unsigned short i = 0; i < 10; ++i)  
  {
    fillImageWithRawData(rawImage, i);

    convert->SetI0(i);

    clock.Start();

    convert->Update();

    clock.Stop();
  }

  // If all succeed
  std::cout << "\n\nTest PASSED! " << std::endl;

  return EXIT_SUCCESS;
}<commit_msg>update imagx lut test<commit_after>#include "rtkTest.h"
#include "rtkMacro.h"
#include "rtkLUTbasedVariableI0RawToAttImageFilter.h"
#include <itkTimeProbe.h>
#include <itkImageRegionIterator.h>

/**
 * \file rtklutbasedvarI0rawtoatttest.cxx
 *
 * \brief Test rtk::LUTbasedVariableI0RawToAttImageFilter
 *
 * \author <NAME>
 */

typedef itk::Image<unsigned short, 2> ShortImageType;
typedef itk::Image<float, 2> FloatImageType;

void fillImageWithRawData(ShortImageType::Pointer image, unsigned short I0)
{
  itk::ImageRegionIterator<itk::Image<unsigned short, 2>> it(image, image->GetLargestPossibleRegion());
  it.GoToBegin();
  unsigned short i = 0;
  while (!it.IsAtEnd()){
    unsigned short I = (i%I0)+1;
    it.Set(I);
    ++it;
    ++i;
  }
}

int main(int, char** )
{
  itk::TimeProbe clock;
  
  typedef rtk::LUTbasedVariableI0RawToAttImageFilter ConvertFilterType;
  ConvertFilterType::Pointer convert = ConvertFilterType::New();
  
  // Constant image sources
  ShortImageType::SizeType size;
  size[0] = 10;
  size[1] = 10;
  ShortImageType::IndexType start;
  start.Fill(0);
  ShortImageType::RegionType region;
  region.SetIndex(start);
  region.SetSize(size);
  ShortImageType::SpacingType spacings;
  spacings[0] = 1.0;
  spacings[1] = 1.0;
  
  ShortImageType::Pointer rawImage = ShortImageType::New();
  rawImage->SetRegions(region);
  rawImage->SetSpacing(spacings);
  rawImage->Allocate();

  convert->SetInput(rawImage);

  for (unsigned short i = 0; i < 10; ++i)  
  {
    unsigned short I0 = 10 * i + 1;

    fillImageWithRawData(rawImage, I0);

    convert->SetI0(I0/2);

    clock.Start();

    convert->Update();

    clock.Stop();
  }

  // If all succeed
  std::cout << "\n\nTest PASSED! " << std::endl;

  return EXIT_SUCCESS;
}
{'fraction_non_alphanumeric': 0.1443631039531479, 'fraction_numerical': 0.01786237188872621, 'mean_word_length': 4.636963696369637, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7474335', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1242, 'n_words': 229}