<commit_before>#include <assert.h>
#include <cstdint>
#include <iostream>
#include <memory>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

#include <imp/core/roi.hpp>
#include <imp/core/image_raw.hpp>
#include <imp/bridge/opencv/image_cv.hpp>
#include <imp/cu_core/cu_image_gpu.cuh>
#include <imp/cu_imgproc/cu_tvl1_denoising.cuh>
#include <imp/bridge/opencv/cu_cv_bridge.hpp>

int main(int argc, char** argv)
{
  try
  {
    if (argc < 2)
    {
      std::cout << "usage: cu_tvl1_denoising_test input";
    }
    std::string in_filename(argv[1]);

    // 8uC1
    {
      std::shared_ptr<imp::cu::ImageGpu8uC1> d_lena;
      imp::cu::cvBridgeLoad(d_lena, in_filename, imp::PixelOrder::gray);
      std::shared_ptr<imp::cu::ImageGpu8uC1> d_lena_denoised(
            new imp::cu::ImageGpu8uC1(*d_lena));

      imp::cu::TvL1Denoising8uC1 tvl1;
      tvl1.params().lambda = 0.5f;
      std::cout << "\n" << tvl1 << std::endl << std::endl;
      tvl1.denoise(d_lena_denoised, d_lena);

      // show results
      imp::cu::cvBridgeShow("lena input 8u", *d_lena);
      imp::cu::cvBridgeShow("lena denoised 8u", *d_lena_denoised);
    }

    // 32fC1
    {
      std::shared_ptr<imp::cu::ImageGpu32fC1> d1_lena;
      imp::cu::cvBridgeLoad(d1_lena, "/home/mwerlberger/data/std/Lena.tiff",
                            imp::PixelOrder::gray);
      std::shared_ptr<imp::cu::ImageGpu32fC1> d_lena_denoised(
            new imp::cu::ImageGpu32fC1(*d1_lena));

      imp::cu::TvL1Denoising32fC1 tvl1;
      tvl1.params().lambda = 0.5f;
      std::cout << "\n" << tvl1 << std::endl << std::endl;
      tvl1.denoise(d_lena_denoised, d1_lena);

      imp::cu::cvBridgeShow("lena input 32f", *d1_lena);
      imp::cu::cvBridgeShow("lena denoised 32f", *d_lena_denoised);
    }

    cv::waitKey();
  }
  catch (std::exception& e)
  {
    std::cout << "[exception] " << e.what() << std::endl;
    assert(false);
  }

  return EXIT_SUCCESS;

}
<commit_msg>changed tvl1 tool to use filename to load image<commit_after>#include <assert.h>
#include <cstdint>
#include <iostream>
#include <memory>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

#include <imp/core/roi.hpp>
#include <imp/core/image_raw.hpp>
#include <imp/bridge/opencv/image_cv.hpp>
#include <imp/cu_core/cu_image_gpu.cuh>
#include <imp/cu_imgproc/cu_tvl1_denoising.cuh>
#include <imp/bridge/opencv/cu_cv_bridge.hpp>

int main(int argc, char** argv)
{
  try
  {
    if (argc < 2)
    {
      std::cout << "usage: cu_tvl1_denoising_test input_image_filename";
      return EXIT_FAILURE;
    }
    std::string in_filename(argv[1]);

    // 8uC1
    {
      std::shared_ptr<imp::cu::ImageGpu8uC1> d_lena;
      imp::cu::cvBridgeLoad(d_lena, in_filename, imp::PixelOrder::gray);
      std::shared_ptr<imp::cu::ImageGpu8uC1> d_lena_denoised(
            new imp::cu::ImageGpu8uC1(*d_lena));

      imp::cu::TvL1Denoising8uC1 tvl1;
      tvl1.params().lambda = 0.5f;
      std::cout << "\n" << tvl1 << std::endl << std::endl;
      tvl1.denoise(d_lena_denoised, d_lena);

      // show results
      imp::cu::cvBridgeShow("lena input 8u", *d_lena);
      imp::cu::cvBridgeShow("lena denoised 8u", *d_lena_denoised);
    }

    // 32fC1
    {
      std::shared_ptr<imp::cu::ImageGpu32fC1> d1_lena;
      imp::cu::cvBridgeLoad(d1_lena, in_filename, imp::PixelOrder::gray);
      std::shared_ptr<imp::cu::ImageGpu32fC1> d_lena_denoised(
            new imp::cu::ImageGpu32fC1(*d1_lena));

      imp::cu::TvL1Denoising32fC1 tvl1;
      tvl1.params().lambda = 0.5f;
      std::cout << "\n" << tvl1 << std::endl << std::endl;
      tvl1.denoise(d_lena_denoised, d1_lena);

      imp::cu::cvBridgeShow("lena input 32f", *d1_lena);
      imp::cu::cvBridgeShow("lena denoised 32f", *d_lena_denoised);
    }

    cv::waitKey();
  }
  catch (std::exception& e)
  {
    std::cout << "[exception] " << e.what() << std::endl;
    assert(false);
  }

  return EXIT_SUCCESS;

}

{'fraction_non_alphanumeric': 0.17058377558756635, 'fraction_numerical': 0.028556987616881475, 'mean_word_length': 3.575722543352601, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 35, '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': '6798703', 'n_tokens_mistral': 1718, 'n_tokens_neox': 1660, 'n_words': 230}