1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/// Struct representing an image (up to 4 dimensions wide), each pixel being of type T.
///
/// This is the main class of the CImg Library. It declares and constructs an image,
/// allows access to its pixel values, and is able to perform various image operations.
///
/// ## Image representation
///
/// A RImg image is defined as an instance of the container RImg<T>, which contains a
/// regular grid of pixels, each pixel value being of type T. The image grid can have
/// up to 4 dimensions: width, height, depth and number of channels. Usually, the three
/// first dimensions are used to describe spatial coordinates (x,y,z), while the number
/// of channels is rather used as a vector-valued dimension (it may describe the R,G,B
/// color channels for instance).
///
/// Thus, the RImg<T> struct is able to represent volumetric images of vector-valued
/// pixels, as well as images with less dimensions (1D scalar signal, 2D color images, ...).
/// Most member functions of the struct RImg<T> are designed to handle this maximum case
/// of (3+1) dimensions.
///
/// Concerning the pixel value type T: fully supported template types are Rust primitive
/// number types:
///
/// * Integers: `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`,
/// `isize`, `usize`
/// * Floats: `f32`, `f64`
///
/// Typically, fast image display can be done using CImg<u8> images, while
/// complex image processing algorithms may be rather coded using RImg<f32> or RImg<f54>
/// images that have floating-point pixel values. The default value for the template T is
/// f32. Using your own template types may be possible.
///
/// ## Image structure
///
/// The RImg<T> structure contains five fields:
///
/// * `width` defines the number of columns of the image (size along the X-axis).
/// * `height` defines the number of rows of the image (size along the Y-axis).
/// * `depth` defines the number of slices of the image (size along the Z-axis).
/// * `spectrum` defines the number of channels of the image (size along the C-axis).
/// * `data` defines a pointer to the pixel data (of type T).
///
/// You can access these fields the dedicated functions `width()`, `height()`, `depth()`,
/// `spectrum()` and `vec()` to do so. Image dimensions are not limited to a specific range
/// (as long as you got enough available memory). A value of 1 usually means that the
/// corresponding dimension is *flat*. If one of the dimensions is 0, or if the data pointer is null,
/// the image is considered as empty. Empty images should not contain any pixel data and thus,
/// will not be processed by RImg member functions (an Error Status will be returned instead).
/// Pixel data are stored in memory, in a non interlaced mode.