/* Copyright (c) 2020 CNRS All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDi WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include //Command-line parsing #include "CLI11.hpp" //Image filtering and I/O #define cimg_display 0 #include "CImg.h" #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" //Global flag to silent verbose messages bool silent; int main(int argc, char **argv) { CLI::App app{"MCMonteCarlo"}; std::string sourceImage; app.add_option("-i,--input", sourceImage, "Source image")->required()->check(CLI::ExistingFile);; std::string outputImage= "output.png"; app.add_option("-o,--output", outputImage, "Output image")->required(); unsigned int nbSpp = 100; app.add_option("-n,--nbspp", nbSpp, "Number of samples"); unsigned int nbSteps = 3; app.add_option("-s,--steps", nbSteps, "Number of steps"); silent = false; app.add_flag("--silent", silent, "No verbose messages"); CLI11_PARSE(app, argc, argv); //Image loading int width,height, nbChannels; unsigned char *source = stbi_load(sourceImage.c_str(), &width, &height, &nbChannels, 0); if (!silent) std::cout<< "Source image: "< output(width*height*nbChannels); for(auto i=0; i < width*height*nbChannels; ++i) output[i] = source[i]; //Final export if (!silent) std::cout<<"Exporting.."<