blob: 0d43db1455174c9f6fa8248e50535af38e351940 [file] [log] [blame]
Austin Schuh8c794d52019-03-03 21:17:37 -08001/*
2 #
3 # File : use_chlpca.cpp
4 # ( C++ source file )
5 #
6 # Description : Example of use for the CImg plugin 'plugins/chlpca.h'.
7 # This file is a part of the CImg Library project.
8 # ( http://cimg.eu )
9 #
10 # Copyright : Jerome Boulanger
11 # ( http://www.irisa.fr/vista/Equipe/People/Jerome.Boulanger.html )
12 #
13 #
14 # License : CeCILL v2.0
15 # ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
16 #
17 # This software is governed by the CeCILL license under French law and
18 # abiding by the rules of distribution of free software. You can use,
19 # modify and/ or redistribute the software under the terms of the CeCILL
20 # license as circulated by CEA, CNRS and INRIA at the following URL
21 # "http://www.cecill.info".
22 #
23 # As a counterpart to the access to the source code and rights to copy,
24 # modify and redistribute granted by the license, users are provided only
25 # with a limited warranty and the software's author, the holder of the
26 # economic rights, and the successive licensors have only limited
27 # liability.
28 #
29 # In this respect, the user's attention is drawn to the risks associated
30 # with loading, using, modifying and/or developing or reproducing the
31 # software by the user in light of its specific status of free software,
32 # that may mean that it is complicated to manipulate, and that also
33 # therefore means that it is reserved for developers and experienced
34 # professionals having in-depth computer knowledge. Users are therefore
35 # encouraged to load and test the software's suitability as regards their
36 # requirements in conditions enabling the security of their systems and/or
37 # data to be ensured and, more generally, to use and operate it in the
38 # same conditions as regards security.
39 #
40 # The fact that you are presently reading this means that you have had
41 # knowledge of the CeCILL license and that you accept its terms.
42 #
43*/
44
45#define cimg_plugin "plugins/chlpca.h"
46#include "CImg.h"
47using namespace cimg_library;
48#ifndef cimg_imagepath
49#define cimg_imagepath "img/"
50#endif
51
52// Main procedure
53//----------------
54int main(int argc,char **argv) {
55 cimg_usage("Patch based denoising ");
56 const char *file_i = cimg_option("-i",cimg_imagepath "milla.bmp","Input image");
57 const int p = cimg_option("-p",3,"patch radius");
58 const int w = cimg_option("-w",10,"window radius");
59 const float lambda_min = cimg_option("-l",(float)2.f,"component selection threshold");
60 const int nstep = cimg_option("-nstep",5,"sub-sampling");
61 const float nsim = cimg_option("-nsim",(float)5.f,"dictionnary size a multiple of the patch size");
62 const float noise_std = cimg_option("-sigma",(float)-1.f,"noise std (-1:estimated)");
63 const bool use_svd = cimg_option("-svd",(float)-1.f,"use svd for computing PCA");
64 const char *file_o = cimg_option("-o",(char*)NULL,"Output file");
65 CImg<> img(file_i);
66 img = img.get_chlpca(p, w, nstep, nsim, lambda_min, noise_std, use_svd);
67 img.display();
68 if (file_o) img.save(file_o);
69 return 0;
70}