cimg.cxx 3.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.txt ADDED
@@ -0,0 +1,180 @@
1
+ --------------------------------------------------------------------------------
2
+ --------------------------------------------------------------------------------
3
+ ____ _ _ ____
4
+ (_ _)( )_( )( ___)
5
+ )( ) _ ( )__)
6
+ (__) (_) (_)(____)
7
+ ___ ____ __ __ ___ __ ____ ____ ____ __ ____ _ _
8
+ / __)(_ _)( \/ )/ __) ( ) (_ _)( _ \( _ \ /__\ ( _ \( \/ )
9
+ ( (__ _)(_ ) (( (_-. )(__ _)(_ ) _ < ) / /(__)\ ) / \ /
10
+ \___)(____)(_/\/\_)\___/ (____)(____)(____/(_)\_)(__)(__)(_)\_) (__)
11
+
12
+
13
+ C++ Template Image Processing Toolkit
14
+
15
+ ( http://cimg.eu )
16
+
17
+ _cimg_version
18
+
19
+ --------------------------------------------------------------------------------
20
+
21
+ # Summary
22
+ #---------
23
+
24
+ The CImg Library is a small and open-source C++ toolkit for image processing.
25
+ It consists in a single header file 'CImg.h' providing a minimal set of C++
26
+ classes and methods that can be used in your own sources, to load/save,
27
+ process and display images. Very portable (Unix/X11,Windows, MacOS X, FreeBSD, .. ),
28
+ efficient, easy to use, it's a pleasant library for developing image processing
29
+ algorithms in C++.
30
+
31
+ # Authors and contributors :
32
+ #----------------------------
33
+
34
+ - David Tschumperlé (project leader) ( http://tschumperle.users.greyc.fr/ )
35
+
36
+ - Maksim Aizenshtein
37
+ - Alberto Albiol
38
+ - Antonio Albiol
39
+ - Simon Barthelme
40
+ - Neil Brown
41
+ - Haz-Edine Assemlal
42
+ - Vincent Barra
43
+ - Wolf Blecher
44
+ - Romain Blei
45
+ - Yohan Bentolila
46
+ - Jerome Boulanger
47
+ - Pierre Buyssens
48
+ - Sebastien Coudert
49
+ - Frederic Devernay
50
+ - Olivier D'Hondt
51
+ - Francois-Xavier Dupe
52
+ - Gerd von Egidy
53
+ - Eric Fausett
54
+ - Jean-Marie Favreau
55
+ - Sebastien Fourey
56
+ - Alexandre Fournier
57
+ - Hon-Kwok Fung
58
+ - Vincent Garcia
59
+ - David Grimbichler
60
+ - Jinwei Gu
61
+ - Jean-Daniel Guyot
62
+ - Cedric Hammiche
63
+ - Matt Hanson
64
+ - Sebastien Hanel
65
+ - Michael Holroyd
66
+ - Christoph Hormann
67
+ - Werner Jainek
68
+ - Daniel Kondermann
69
+ - Pierre Kornprobst
70
+ - Jan W. Krieger
71
+ - Orges Leka
72
+ - Francois Lauze
73
+ - Xie Long
74
+ - Thomas Martin
75
+ - Cesar Martinez
76
+ - Jean Martinot
77
+ - Arnold Meijster (Center for High Performance Computing and Visualization, University of Groningen/The Netherlands)
78
+ - Nikita Melnichenko
79
+ - Julien Morat
80
+ - Baptiste Mougel
81
+ - Jovana Milutinovich
82
+ - Guillaume Nee
83
+ - Adam Newgas
84
+ - Francisco Oliveira
85
+ - Andrea Onofri
86
+ - Renaud Peteri
87
+ - Martin Petricek
88
+ - Paolo Prete
89
+ - Adrien Reboisson
90
+ - Klaus Schneider
91
+ - Jakob Schluttig
92
+ - Jamie Smith
93
+ - Veronique Souchaud
94
+ - Konstantin Spirin
95
+ - David G. Starkweather
96
+ - Rainer Steffens
97
+ - Grzegorz Szwoch
98
+ - Thierry Thomas
99
+ - Yu-En-Yun
100
+ - Vo Duc Khanh
101
+ - Phillip Wood
102
+ - Bug Zhao
103
+ - Haibo Zheng
104
+
105
+ # Institution
106
+ #-------------
107
+
108
+ GREYC Image / CNRS UMR 6072 / FRANCE
109
+
110
+ The CImg Library project started in 2000, at the INRIA-Sophia
111
+ Antipolis/France ( http://www-sop.inria.fr/ ), in the ROBOTVIS / ODYSSEE Team.
112
+ Since October 2004, it is maintained and developed in the Image team of
113
+ the GREYC Lab (CNRS, UMR 6072), in Caen/France.
114
+ Team web page : http://www.greyc.fr/image
115
+
116
+ # Licenses
117
+ #----------
118
+
119
+ The source code of the CImg Library is distributed under
120
+ two distinct licenses :
121
+
122
+ - The main library file 'CImg.h' is *dual-licensed* :
123
+ It can be either distributed under the CeCILL-C or CeCILL license.
124
+ (see files 'Licence_CeCILL-C_V1-en.txt' and 'Licence_CeCILL_V2-en.txt').
125
+ Both are Free-Software licenses :
126
+
127
+ * CeCILL-C is adapted to the distribution of
128
+ library components, and is close in its terms to the well known GNU LGPL license
129
+ (the 'CImg.h' file can thus be used in closed-source products under certain
130
+ conditions, please read carefully the license file).
131
+
132
+ * CeCILL is close to (and even compatible with) the GNU GPL license.
133
+
134
+ - Most of the other files are distributed under the CeCiLL license
135
+ (file 'Licence_CeCILL_V2-en.txt'). See each file header to see what license applies.
136
+
137
+ These two CeCiLL licenses ( http://www.cecill.info/index.en.html ) have been
138
+ created under the supervision of the three biggest research institutions on
139
+ computer sciences in France :
140
+
141
+ - CNRS ( http://www.cnrs.fr/ )
142
+ - CEA ( http://www.cea.fr/ )
143
+ - INRIA ( http://www.inria.fr/ )
144
+
145
+ You have to RESPECT these licenses. More particularly, please carefully read
146
+ the license terms before using the CImg library in commercial products.
147
+
148
+ # Package structure :
149
+ #--------------------
150
+
151
+ The main package directory CImg/ is organized as follows :
152
+
153
+ - README.txt : This file.
154
+ - Licence_CeCILL-C_V1-en.txt : A copy of the CeCiLL-C license file.
155
+ - Licence_CeCILL_V2-en.txt : A copy of the CeCiLL license.
156
+ - CImg.h : The single header file that constitutes the library itself.
157
+ - examples/ : A directory containing a lot of example programs performing
158
+ various things, using the CImg library.
159
+ - html/ : A directory containing a copy of the CImg web page in html
160
+ format. The reference documentation is generated
161
+ automatically with the tool 'doxygen' (http://www.doxygen.org).
162
+ - resources/ : A directory containing some resources files for compiling
163
+ CImg examples or packages with various C++ compilers and OS.
164
+ - plugins/ : A directory containing CImg plug-ins files that can be used to
165
+ add specific extra functionalities to the CImg library.
166
+
167
+ # Getting started
168
+ #-----------------
169
+
170
+ If you are new to CImg, you should first try to compile the different examples
171
+ provided in the 'examples/' directory, to see what CImg is capable of
172
+ (as CImg is a template-based library, no prior compilation of the library is mandatory).
173
+ Look at the 'resources/' directory to ease this compilation on different platforms.
174
+
175
+ Then, you can look at the documentation 'html/reference/' to learn more about CImg
176
+ functions and classes. Finally, you can participate to the 'Forum' section
177
+ of the CImg web page and ask for help if needed.
178
+
179
+ # End of file
180
+ #------------
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "cimg.cxx",
3
+ "version": "3.6.3",
4
+ "description": "The CImg Library is a small and open-source C++ toolkit for image processing; GREYC (2018).",
5
+ "keywords": ["c", "library", "image", "processing", "cimg"],
6
+ "license": "CeCILL",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/nodef/cimg.cxx.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/nodef/cimg.cxx/issues"
13
+ },
14
+ "homepage": "https://github.com/nodef/cimg.cxx#readme"
15
+ }
@@ -0,0 +1,79 @@
1
+ /*
2
+ #
3
+ # File : add_fileformat.h
4
+ # ( C++ header file - CImg plug-in )
5
+ #
6
+ # Description : CImg plug-in that adds loading/saving support for a personalized
7
+ # file format (determined by its extension, here ".foo").
8
+ # This file is a part of the CImg Library project.
9
+ # ( http://cimg.eu )
10
+ #
11
+ # Copyright : David Tschumperlé
12
+ # ( http://tschumperle.users.greyc.fr/ )
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
+ #ifndef cimg_plugin_addfileformat
46
+ #define cimg_plugin_addfileformat
47
+
48
+ // These functions load ".foo" filenames
49
+ //---------------------------------------
50
+ static CImg<T> get_load_foo(const char *filename) {
51
+ std::fprintf(stderr,"Load '%s' here..\n",filename);
52
+ return CImg<T>(512,512,1,3,0).noise(30);
53
+ }
54
+
55
+ CImg& load_foo(const char *filename) {
56
+ return get_load_foo(filename).swap(*this);
57
+ }
58
+
59
+ // This function saves the instance image into a ".foo" file.
60
+ //-----------------------------------------------------------
61
+ const CImg& save_foo(const char *filename) const {
62
+ std::fprintf(stderr,"Save '%s' here..\n",filename);
63
+ return *this;
64
+ }
65
+
66
+ // The code below allows to add the support for the specified extension.
67
+ //---------------------------------------------------------------------
68
+ #ifndef cimg_load_plugin
69
+ #define cimg_load_plugin(filename) \
70
+ if (!cimg::strncasecmp(cimg::split_filename(filename),"foo",3)) return load_foo(filename);
71
+ #endif
72
+ #ifndef cimg_save_plugin
73
+ #define cimg_save_plugin(filename) \
74
+ if (!cimg::strncasecmp(cimg::split_filename(filename),"foo",3)) return save_foo(filename);
75
+ #endif
76
+
77
+ // End of the plugin.
78
+ //-------------------
79
+ #endif /* cimg_plugin_addfileformat */
@@ -0,0 +1,212 @@
1
+ /*
2
+ #
3
+ # File : bayer.h
4
+ # ( C++ header file - CImg plug-in )
5
+ #
6
+ # Description : CImg plugin that implements the conversion of a color image to a
7
+ # Bayer-coded matrix, and its reverse transform.
8
+ #
9
+ # Copyright : David Tschumperlé
10
+ # ( https://tschumperle.users.greyc.fr/ )
11
+ #
12
+ # This software is governed by the CeCILL license under French law and
13
+ # abiding by the rules of distribution of free software. You can use,
14
+ # modify and/or redistribute the software under the terms of the CeCILL
15
+ # license as circulated by CEA, CNRS and INRIA at the following URL
16
+ # "http://www.cecill.info".
17
+ #
18
+ # As a counterpart to the access to the source code and rights to copy,
19
+ # modify and redistribute granted by the license, users are provided only
20
+ # with a limited warranty and the software's author, the holder of the
21
+ # economic rights, and the successive licensors have only limited
22
+ # liability.
23
+ #
24
+ # In this respect, the user's attention is drawn to the risks associated
25
+ # with loading, using, modifying and/or developing or reproducing the
26
+ # software by the user in light of its specific status of free software,
27
+ # that may mean that it is complicated to manipulate, and that also
28
+ # therefore means that it is reserved for developers and experienced
29
+ # professionals having in-depth computer knowledge. Users are therefore
30
+ # encouraged to load and test the software's suitability as regards their
31
+ # requirements in conditions enabling the security of their systems and/or
32
+ # data to be ensured and, more generally, to use and operate it in the
33
+ # same conditions as regards security.
34
+ #
35
+ # The fact that you are presently reading this means that you have had
36
+ # knowledge of the CeCILL license and that you accept its terms.
37
+ #
38
+ */
39
+ #ifndef cimg_plugin_bayer
40
+ #define cimg_plugin_bayer
41
+
42
+ //! Convert RGB color image to a Bayer-coded scalar image.
43
+ /**
44
+ \note First (upper-left) pixel if the red component of the pixel color.
45
+ **/
46
+ CImg<T>& RGBtoBayer() {
47
+ return get_RGBtoBayer().move_to(*this);
48
+ }
49
+
50
+ //! Convert RGB color image to a Bayer-coded scalar image \newinstance.
51
+ CImg<T> get_RGBtoBayer() const {
52
+ if (_spectrum!=3)
53
+ throw CImgInstanceException(_cimg_instance
54
+ "RGBtoBayer(): Instance is not a RGB image.",
55
+ cimg_instance);
56
+
57
+ CImg<T> res(_width,_height,_depth,1);
58
+ const T *ptr_r = data(0,0,0,0), *ptr_g = data(0,0,0,1), *ptr_b = data(0,0,0,2);
59
+ T *ptrd = res._data;
60
+ cimg_forXYZ(*this,x,y,z) {
61
+ if (y%2) {
62
+ if (x%2) *(ptrd++) = *ptr_b;
63
+ else *(ptrd++) = *ptr_g;
64
+ } else {
65
+ if (x%2) *(ptrd++) = *ptr_g;
66
+ else *(ptrd++) = *ptr_r;
67
+ }
68
+ ++ptr_r; ++ptr_g; ++ptr_b;
69
+ }
70
+ return res;
71
+ }
72
+
73
+ //! Convert Bayer-coded scalar image to a RGB color image.
74
+ CImg<T>& BayertoRGB(const unsigned int interpolation_type=3) {
75
+ return get_BayertoRGB(interpolation_type).move_to(*this);
76
+ }
77
+
78
+ //! Convert Bayer-coded scalar image to a RGB color image \newinstance.
79
+ CImg<Tuchar> get_BayertoRGB(const unsigned int interpolation_type=3) const {
80
+ if (_spectrum!=1)
81
+ throw CImgInstanceException(_cimg_instance
82
+ "BayertoRGB(): Instance is not a Bayer image.",
83
+ cimg_instance);
84
+
85
+ CImg<Tuchar> res(_width,_height,_depth,3);
86
+ CImg_3x3(I,T);
87
+ Tuchar *ptr_r = res.data(0,0,0,0), *ptr_g = res.data(0,0,0,1), *ptr_b = res.data(0,0,0,2);
88
+ switch (interpolation_type) {
89
+ case 3 : { // Edge-directed
90
+ CImg_3x3(R,T);
91
+ CImg_3x3(G,T);
92
+ CImg_3x3(B,T);
93
+ cimg_forXYZ(*this,x,y,z) {
94
+ const int _p1x = x?x - 1:1, _p1y = y?y - 1:1, _n1x = x<width() - 1?x + 1:x - 1, _n1y = y<height() - 1?y + 1:y - 1;
95
+ cimg_get3x3(*this,x,y,z,0,I,T);
96
+ if (y%2) {
97
+ if (x%2) {
98
+ const Tfloat
99
+ alpha = cimg::sqr((Tfloat)Inc - Ipc),
100
+ beta = cimg::sqr((Tfloat)Icn - Icp),
101
+ cx = 1/(1 + alpha), cy = 1/(1 + beta);
102
+ *ptr_g = (Tuchar)((cx*(Inc + Ipc) + cy*(Icn + Icp))/(2*(cx + cy)));
103
+ } else *ptr_g = (Tuchar)Icc;
104
+ } else {
105
+ if (x%2) *ptr_g = (Tuchar)Icc;
106
+ else {
107
+ const Tfloat
108
+ alpha = cimg::sqr((Tfloat)Inc - Ipc),
109
+ beta = cimg::sqr((Tfloat)Icn - Icp),
110
+ cx = 1/(1 + alpha), cy = 1/(1 + beta);
111
+ *ptr_g = (Tuchar)((cx*(Inc + Ipc) + cy*(Icn + Icp))/(2*(cx + cy)));
112
+ }
113
+ }
114
+ ++ptr_g;
115
+ }
116
+ cimg_forXYZ(*this,x,y,z) {
117
+ const int _p1x = x?x - 1:1, _p1y = y?y - 1:1, _n1x = x<width() - 1?x + 1:x - 1, _n1y = y<height() - 1?y + 1:y - 1;
118
+ cimg_get3x3(*this,x,y,z,0,I,T);
119
+ cimg_get3x3(res,x,y,z,1,G,T);
120
+ if (y%2) {
121
+ if (x%2) *ptr_b = (Tuchar)Icc;
122
+ else { *ptr_r = (Tuchar)((Icn + Icp)/2); *ptr_b = (Tuchar)((Inc + Ipc)/2); }
123
+ } else {
124
+ if (x%2) { *ptr_r = (Tuchar)((Inc + Ipc)/2); *ptr_b = (Tuchar)((Icn + Icp)/2); }
125
+ else *ptr_r = (Tuchar)Icc;
126
+ }
127
+ ++ptr_r; ++ptr_b;
128
+ }
129
+ ptr_r = res.data(0,0,0,0);
130
+ ptr_g = res.data(0,0,0,1);
131
+ ptr_b = res.data(0,0,0,2);
132
+ cimg_forXYZ(*this,x,y,z) {
133
+ const int _p1x = x?x - 1:1, _p1y = y?y - 1:1, _n1x = x<width() - 1?x + 1:x - 1, _n1y = y<height() - 1?y + 1:y - 1;
134
+ cimg_get3x3(res,x,y,z,0,R,T);
135
+ cimg_get3x3(res,x,y,z,1,G,T);
136
+ cimg_get3x3(res,x,y,z,2,B,T);
137
+ if (y%2) {
138
+ if (x%2) {
139
+ const float
140
+ alpha = (float)cimg::sqr(Rnc - Rpc),
141
+ beta = (float)cimg::sqr(Rcn - Rcp),
142
+ cx = 1/(1 + alpha), cy = 1/(1 + beta);
143
+ *ptr_r = (Tuchar)((cx*(Rnc + Rpc) + cy*(Rcn + Rcp))/(2*(cx + cy)));
144
+ }
145
+ } else {
146
+ if (!(x%2)) {
147
+ const float
148
+ alpha = (float)cimg::sqr(Bnc - Bpc),
149
+ beta = (float)cimg::sqr(Bcn - Bcp),
150
+ cx = 1/(1 + alpha), cy = 1/(1 + beta);
151
+ *ptr_b = (Tuchar)((cx*(Bnc + Bpc) + cy*(Bcn + Bcp))/(2*(cx + cy)));
152
+ }
153
+ }
154
+ ++ptr_r; ++ptr_g; ++ptr_b;
155
+ }
156
+ } break;
157
+ case 2 : { // Linear interpolation
158
+ cimg_forXYZ(*this,x,y,z) {
159
+ const int _p1x = x?x - 1:1, _p1y = y?y - 1:1, _n1x = x<width() - 1?x + 1:x - 1, _n1y = y<height() - 1?y + 1:y - 1;
160
+ cimg_get3x3(*this,x,y,z,0,I,T);
161
+ if (y%2) {
162
+ if (x%2) {
163
+ *ptr_r = (Tuchar)((Ipp + Inn + Ipn + Inp)/4);
164
+ *ptr_g = (Tuchar)((Inc + Ipc + Icn + Icp)/4);
165
+ *ptr_b = (Tuchar)Icc;
166
+ } else { *ptr_r = (Tuchar)((Icp + Icn)/2); *ptr_g = (Tuchar)Icc; *ptr_b = (Tuchar)((Inc + Ipc)/2); }
167
+ } else {
168
+ if (x%2) { *ptr_r = (Tuchar)((Ipc + Inc)/2); *ptr_g = (Tuchar)Icc; *ptr_b = (Tuchar)((Icn + Icp)/2); }
169
+ else {
170
+ *ptr_r = (Tuchar)Icc;
171
+ *ptr_g = (Tuchar)((Inc + Ipc + Icn + Icp)/4);
172
+ *ptr_b = (Tuchar)((Ipp + Inn + Ipn + Inp)/4);
173
+ }
174
+ }
175
+ ++ptr_r; ++ptr_g; ++ptr_b;
176
+ }
177
+ } break;
178
+ case 1 : { // Nearest neighbor interpolation
179
+ cimg_forXYZ(*this,x,y,z) {
180
+ const int _p1x = x?x - 1:1, _p1y = y?y - 1:1, _n1x = x<width() - 1?x + 1:x - 1, _n1y = y<height() - 1?y + 1:y - 1;
181
+ cimg_get3x3(*this,x,y,z,0,I,T);
182
+ if (y%2) {
183
+ if (x%2) {
184
+ *ptr_r = (Tuchar)cimg::min(Ipp,Inn,Ipn,Inp);
185
+ *ptr_g = (Tuchar)cimg::min(Inc,Ipc,Icn,Icp);
186
+ *ptr_b = (Tuchar)Icc;
187
+ } else { *ptr_r = (Tuchar)cimg::min(Icn,Icp); *ptr_g = (Tuchar)Icc; *ptr_b = (Tuchar)cimg::min(Inc,Ipc); }
188
+ } else {
189
+ if (x%2) { *ptr_r = (Tuchar)cimg::min(Inc,Ipc); *ptr_g = (Tuchar)Icc; *ptr_b = (Tuchar)cimg::min(Icn,Icp); }
190
+ else {
191
+ *ptr_r = (Tuchar)Icc;
192
+ *ptr_g = (Tuchar)cimg::min(Inc,Ipc,Icn,Icp);
193
+ *ptr_b = (Tuchar)cimg::min(Ipp,Inn,Ipn,Inp);
194
+ }
195
+ }
196
+ ++ptr_r; ++ptr_g; ++ptr_b;
197
+ }
198
+ } break;
199
+ default : { // 0-filling interpolation
200
+ const T *ptrs = _data;
201
+ res.fill(0);
202
+ cimg_forXYZ(*this,x,y,z) {
203
+ const T val = *(ptrs++);
204
+ if (y%2) { if (x%2) *ptr_b = val; else *ptr_g = val; } else { if (x%2) *ptr_g = val; else *ptr_r = val; }
205
+ ++ptr_r; ++ptr_g; ++ptr_b;
206
+ }
207
+ }
208
+ }
209
+ return res;
210
+ }
211
+
212
+ #endif /* cimg_plugin_bayer */