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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
pub mod fuzzy {
//! # Image processing based on fuzzy mathematics
//!
//! Namespace for all functions is `ft`. The module brings implementation of the last image processing algorithms based on fuzzy mathematics. Method are named based on the pattern `FT`_degree_dimension`_`method.
//! # Math with F0-transform support
//!
//! Fuzzy transform (-transform) of the 0th degree transforms whole image to a matrix of its components. These components are used in latter computation where each of them represents average color of certain subarea.
//!
//! # Math with F1-transform support
//!
//! Fuzzy transform (-transform) of the 1th degree transforms whole image to a matrix of its components. Each component is polynomial of the 1th degree carrying information about average color and average gradient of certain subarea.
//!
//! # Fuzzy image processing
//!
//! Image proceesing based on fuzzy mathematics namely F-transform.
use crate::{mod_prelude::*, core, sys, types};
pub mod prelude {
pub use { };
}
/// processing in several iterations
pub const ITERATIVE: i32 = 3;
/// linear (triangular) shape
pub const LINEAR: i32 = 1;
/// processing in multiple step
pub const MULTI_STEP: i32 = 2;
/// processing in one step
pub const ONE_STEP: i32 = 1;
/// sinusoidal shape
pub const SINUS: i32 = 2;
/// Sligtly less accurate version of -transfrom computation optimized for higher speed. The methods counts with linear basic function.
/// ## Parameters
/// * matrix: Input 3 channels matrix.
/// * radius: Radius of the `ft::LINEAR` basic function.
/// * output: Output array.
///
/// This function computes F-transfrom and inverse F-transfotm using linear basic function in one step. It is ~10 times faster than `ft::FT02D_process` method.
#[inline]
pub fn ft02_d_fl_process(matrix: &impl core::ToInputArray, radius: i32, output: &mut impl core::ToOutputArray) -> Result<()> {
input_array_arg!(matrix);
output_array_arg!(output);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_FT02D_FL_process_const__InputArrayR_const_int_const__OutputArrayR(matrix.as_raw__InputArray(), radius, output.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Sligtly less accurate version of -transfrom computation optimized for higher speed. The methods counts with linear basic function.
/// ## Parameters
/// * matrix: Input 3 channels matrix.
/// * radius: Radius of the `ft::LINEAR` basic function.
/// * output: Output array.
///
/// This function computes F-transfrom and inverse F-transfotm using linear basic function in one step. It is ~9 times faster then `ft::FT02D_process` method and more accurate than `ft::FT02D_FL_process` method.
#[inline]
pub fn ft02_d_fl_process_float(matrix: &impl core::ToInputArray, radius: i32, output: &mut impl core::ToOutputArray) -> Result<()> {
input_array_arg!(matrix);
output_array_arg!(output);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_FT02D_FL_process_float_const__InputArrayR_const_int_const__OutputArrayR(matrix.as_raw__InputArray(), radius, output.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Computes components of the array using direct -transform.
/// ## Parameters
/// * matrix: Input array.
/// * kernel: Kernel used for processing. Function `ft::createKernel` can be used.
/// * components: Output 32-bit float array for the components.
/// * mask: Mask can be used for unwanted area marking.
///
/// The function computes components using predefined kernel and mask.
///
/// ## C++ default parameters
/// * mask: noArray()
#[inline]
pub fn ft02_d_components(matrix: &impl core::ToInputArray, kernel: &impl core::ToInputArray, components: &mut impl core::ToOutputArray, mask: &impl core::ToInputArray) -> Result<()> {
input_array_arg!(matrix);
input_array_arg!(kernel);
output_array_arg!(components);
input_array_arg!(mask);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_FT02D_components_const__InputArrayR_const__InputArrayR_const__OutputArrayR_const__InputArrayR(matrix.as_raw__InputArray(), kernel.as_raw__InputArray(), components.as_raw__OutputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Computes inverse -transfrom.
/// ## Parameters
/// * components: Input 32-bit float single channel array for the components.
/// * kernel: Kernel used for processing. Function `ft::createKernel` can be used.
/// * output: Output 32-bit float array.
/// * width: Width of the output array.
/// * height: Height of the output array.
///
/// Computation of inverse F-transform.
#[inline]
pub fn ft02_d_inverse_ft(components: &impl core::ToInputArray, kernel: &impl core::ToInputArray, output: &mut impl core::ToOutputArray, width: i32, height: i32) -> Result<()> {
input_array_arg!(components);
input_array_arg!(kernel);
output_array_arg!(output);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_FT02D_inverseFT_const__InputArrayR_const__InputArrayR_const__OutputArrayR_int_int(components.as_raw__InputArray(), kernel.as_raw__InputArray(), output.as_raw__OutputArray(), width, height, ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Computes -transfrom and inverse -transfrom at once and return state.
/// ## Parameters
/// * matrix: Input matrix.
/// * kernel: Kernel used for processing. Function `ft::createKernel` can be used.
/// * output: Output 32-bit float array.
/// * mask: Mask used for unwanted area marking.
/// * maskOutput: Mask after one iteration.
/// * firstStop: If **true** function returns -1 when first problem appears. In case of `false` the process is completed and summation of all problems returned.
///
/// This function computes iteration of F-transfrom and inverse F-transfotm and handle image and mask change. The function is used in `ft::inpaint` function.
#[inline]
pub fn ft02_d_iteration(matrix: &impl core::ToInputArray, kernel: &impl core::ToInputArray, output: &mut impl core::ToOutputArray, mask: &impl core::ToInputArray, mask_output: &mut impl core::ToOutputArray, first_stop: bool) -> Result<i32> {
input_array_arg!(matrix);
input_array_arg!(kernel);
output_array_arg!(output);
input_array_arg!(mask);
output_array_arg!(mask_output);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_FT02D_iteration_const__InputArrayR_const__InputArrayR_const__OutputArrayR_const__InputArrayR_const__OutputArrayR_bool(matrix.as_raw__InputArray(), kernel.as_raw__InputArray(), output.as_raw__OutputArray(), mask.as_raw__InputArray(), mask_output.as_raw__OutputArray(), first_stop, ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Computes -transfrom and inverse -transfrom at once.
/// ## Parameters
/// * matrix: Input matrix.
/// * kernel: Kernel used for processing. Function `ft::createKernel` can be used.
/// * output: Output 32-bit float array.
/// * mask: Mask used for unwanted area marking.
///
/// This function computes F-transfrom and inverse F-transfotm in one step. It is fully sufficient and optimized for `cv::Mat`.
///
/// ## C++ default parameters
/// * mask: noArray()
#[inline]
pub fn ft02_d_process(matrix: &impl core::ToInputArray, kernel: &impl core::ToInputArray, output: &mut impl core::ToOutputArray, mask: &impl core::ToInputArray) -> Result<()> {
input_array_arg!(matrix);
input_array_arg!(kernel);
output_array_arg!(output);
input_array_arg!(mask);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_FT02D_process_const__InputArrayR_const__InputArrayR_const__OutputArrayR_const__InputArrayR(matrix.as_raw__InputArray(), kernel.as_raw__InputArray(), output.as_raw__OutputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Computes components of the array using direct -transform.
/// ## Parameters
/// * matrix: Input array.
/// * kernel: Kernel used for processing. Function `ft::createKernel` can be used.
/// * components: Output 32-bit float array for the components.
///
/// The function computes linear components using predefined kernel.
#[inline]
pub fn ft12_d_components(matrix: &impl core::ToInputArray, kernel: &impl core::ToInputArray, components: &mut impl core::ToOutputArray) -> Result<()> {
input_array_arg!(matrix);
input_array_arg!(kernel);
output_array_arg!(components);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_FT12D_components_const__InputArrayR_const__InputArrayR_const__OutputArrayR(matrix.as_raw__InputArray(), kernel.as_raw__InputArray(), components.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Creates horizontal matrix for -transform computation.
/// ## Parameters
/// * radius: Radius of the basic function.
/// * matrix: The horizontal matrix.
/// * chn: Number of channels.
///
/// The function creates helper horizontal matrix for -transfrom processing. It is used for gradient computation.
#[inline]
pub fn ft12_d_create_polynom_matrix_horizontal(radius: i32, matrix: &mut impl core::ToOutputArray, chn: i32) -> Result<()> {
output_array_arg!(matrix);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_FT12D_createPolynomMatrixHorizontal_int_const__OutputArrayR_const_int(radius, matrix.as_raw__OutputArray(), chn, ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Creates vertical matrix for -transform computation.
/// ## Parameters
/// * radius: Radius of the basic function.
/// * matrix: The vertical matrix.
/// * chn: Number of channels.
///
/// The function creates helper vertical matrix for -transfrom processing. It is used for gradient computation.
#[inline]
pub fn ft12_d_create_polynom_matrix_vertical(radius: i32, matrix: &mut impl core::ToOutputArray, chn: i32) -> Result<()> {
output_array_arg!(matrix);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_FT12D_createPolynomMatrixVertical_int_const__OutputArrayR_const_int(radius, matrix.as_raw__OutputArray(), chn, ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Computes inverse -transfrom.
/// ## Parameters
/// * components: Input 32-bit float single channel array for the components.
/// * kernel: Kernel used for processing. The same kernel as for components computation must be used.
/// * output: Output 32-bit float array.
/// * width: Width of the output array.
/// * height: Height of the output array.
///
/// Computation of inverse -transform.
#[inline]
pub fn ft12_d_inverse_ft(components: &impl core::ToInputArray, kernel: &impl core::ToInputArray, output: &mut impl core::ToOutputArray, width: i32, height: i32) -> Result<()> {
input_array_arg!(components);
input_array_arg!(kernel);
output_array_arg!(output);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_FT12D_inverseFT_const__InputArrayR_const__InputArrayR_const__OutputArrayR_int_int(components.as_raw__InputArray(), kernel.as_raw__InputArray(), output.as_raw__OutputArray(), width, height, ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Computes elements of -transform components.
/// ## Parameters
/// * matrix: Input array.
/// * kernel: Kernel used for processing. Function `ft::createKernel` can be used.
/// * c00: Elements represent average color.
/// * c10: Elements represent average vertical gradient.
/// * c01: Elements represent average horizontal gradient.
/// * components: Output 32-bit float array for the components.
/// * mask: Mask can be used for unwanted area marking.
///
/// The function computes components and its elements using predefined kernel and mask.
///
/// ## C++ default parameters
/// * mask: noArray()
#[inline]
pub fn ft12_d_polynomial(matrix: &impl core::ToInputArray, kernel: &impl core::ToInputArray, c00: &mut impl core::ToOutputArray, c10: &mut impl core::ToOutputArray, c01: &mut impl core::ToOutputArray, components: &mut impl core::ToOutputArray, mask: &impl core::ToInputArray) -> Result<()> {
input_array_arg!(matrix);
input_array_arg!(kernel);
output_array_arg!(c00);
output_array_arg!(c10);
output_array_arg!(c01);
output_array_arg!(components);
input_array_arg!(mask);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_FT12D_polynomial_const__InputArrayR_const__InputArrayR_const__OutputArrayR_const__OutputArrayR_const__OutputArrayR_const__OutputArrayR_const__InputArrayR(matrix.as_raw__InputArray(), kernel.as_raw__InputArray(), c00.as_raw__OutputArray(), c10.as_raw__OutputArray(), c01.as_raw__OutputArray(), components.as_raw__OutputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Computes -transfrom and inverse -transfrom at once.
/// ## Parameters
/// * matrix: Input matrix.
/// * kernel: Kernel used for processing. Function `ft::createKernel` can be used.
/// * output: Output 32-bit float array.
/// * mask: Mask used for unwanted area marking.
///
/// This function computes -transfrom and inverse -transfotm in one step. It is fully sufficient and optimized for `cv::Mat`.
///
///
/// Note:
/// F-transform technique of first degreee is described in paper [Vlas:FT](https://docs.opencv.org/4.7.0/d0/de3/citelist.html#CITEREF_Vlas:FT).
///
/// ## C++ default parameters
/// * mask: noArray()
#[inline]
pub fn ft12_d_process(matrix: &impl core::ToInputArray, kernel: &impl core::ToInputArray, output: &mut impl core::ToOutputArray, mask: &impl core::ToInputArray) -> Result<()> {
input_array_arg!(matrix);
input_array_arg!(kernel);
output_array_arg!(output);
input_array_arg!(mask);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_FT12D_process_const__InputArrayR_const__InputArrayR_const__OutputArrayR_const__InputArrayR(matrix.as_raw__InputArray(), kernel.as_raw__InputArray(), output.as_raw__OutputArray(), mask.as_raw__InputArray(), ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Creates kernel from basic functions.
/// ## Parameters
/// * A: Basic function used in axis **x**.
/// * B: Basic function used in axis **y**.
/// * kernel: Final 32-bit kernel derived from **A** and **B**.
/// * chn: Number of kernel channels.
///
/// The function creates kernel usable for latter fuzzy image processing.
#[inline]
pub fn create_kernel1(a: &impl core::ToInputArray, b: &impl core::ToInputArray, kernel: &mut impl core::ToOutputArray, chn: i32) -> Result<()> {
input_array_arg!(a);
input_array_arg!(b);
output_array_arg!(kernel);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_createKernel_const__InputArrayR_const__InputArrayR_const__OutputArrayR_const_int(a.as_raw__InputArray(), b.as_raw__InputArray(), kernel.as_raw__OutputArray(), chn, ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Creates kernel from general functions.
/// ## Parameters
/// * function: Function type could be one of the following:
/// * **LINEAR** Linear basic function.
/// * radius: Radius of the basic function.
/// * kernel: Final 32-bit kernel.
/// * chn: Number of kernel channels.
///
/// The function creates kernel from predefined functions.
#[inline]
pub fn create_kernel(function: i32, radius: i32, kernel: &mut impl core::ToOutputArray, chn: i32) -> Result<()> {
output_array_arg!(kernel);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_createKernel_int_int_const__OutputArrayR_const_int(function, radius, kernel.as_raw__OutputArray(), chn, ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Image filtering
/// ## Parameters
/// * image: Input image.
/// * kernel: Final 32-bit kernel.
/// * output: Output 32-bit image.
///
/// Filtering of the input image by means of F-transform.
#[inline]
pub fn filter(image: &impl core::ToInputArray, kernel: &impl core::ToInputArray, output: &mut impl core::ToOutputArray) -> Result<()> {
input_array_arg!(image);
input_array_arg!(kernel);
output_array_arg!(output);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_filter_const__InputArrayR_const__InputArrayR_const__OutputArrayR(image.as_raw__InputArray(), kernel.as_raw__InputArray(), output.as_raw__OutputArray(), ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
/// Image inpainting
/// ## Parameters
/// * image: Input image.
/// * mask: Mask used for unwanted area marking.
/// * output: Output 32-bit image.
/// * radius: Radius of the basic function.
/// * function: Function type could be one of the following:
/// * `ft::LINEAR` Linear basic function.
/// * algorithm: Algorithm could be one of the following:
/// * `ft::ONE_STEP` One step algorithm.
/// * `ft::MULTI_STEP` This algorithm automaticaly increases radius of the basic function.
/// * `ft::ITERATIVE` Iterative algorithm running in more steps using partial computations.
///
/// This function provides inpainting technique based on the fuzzy mathematic.
///
///
/// Note:
/// The algorithms are described in paper [Perf:rec](https://docs.opencv.org/4.7.0/d0/de3/citelist.html#CITEREF_Perf:rec).
#[inline]
pub fn inpaint(image: &impl core::ToInputArray, mask: &impl core::ToInputArray, output: &mut impl core::ToOutputArray, radius: i32, function: i32, algorithm: i32) -> Result<()> {
input_array_arg!(image);
input_array_arg!(mask);
output_array_arg!(output);
return_send!(via ocvrs_return);
unsafe { sys::cv_ft_inpaint_const__InputArrayR_const__InputArrayR_const__OutputArrayR_int_int_int(image.as_raw__InputArray(), mask.as_raw__InputArray(), output.as_raw__OutputArray(), radius, function, algorithm, ocvrs_return.as_mut_ptr()) };
return_receive!(unsafe ocvrs_return => ret);
let ret = ret.into_result()?;
Ok(ret)
}
}