35 if (image !=
nullptr) {
38 if (image->getWidth() != image->getHeight()) {
40 << image->getWidth() <<
" x " << image->getHeight();
42 if (image->getWidth() % 2 == 0) {
47 if (down_scaling != 1.0) {
48 int new_size = image->getWidth() * down_scaling;
49 new_size += (new_size % 2 == 0) ? 1 : 0;
51 auto new_image = Traits::factory(new_size, new_size);
52 Traits::addImageToImage(new_image, image, down_scaling, new_size / 2.0, new_size / 2.0);
56 auto psf_sum =
std::accumulate(new_image->getData().begin(), new_image->getData().end(), 0.);
57 for (
auto& pixel : new_image->getData()) {
61 auto original_psf_sum =
std::accumulate(image->getData().begin(), image->getData().end(), 0.);
62 auto new_psf_sum =
std::accumulate(new_image->getData().begin(), new_image->getData().end(), 0.);
64 for (
auto& pixel : new_image->getData()) {
65 pixel *= original_psf_sum / new_psf_sum;