FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
arrayfire/test/inverse_deconv.cpp at feature/optional-graphics · arrayfire/arrayfire · GitHub
arrayfire
arrayfire
Repository navigation
Code
Issues
292
(292)
Pull requests
39
(39)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
arrayfire
/
test
/
inverse_deconv.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
137 lines (113 loc) · 4.8 KB
Breadcrumbs
arrayfire
/
test
/
inverse_deconv.cpp
Copy path
File metadata and controls
137 lines (113 loc) · 4.8 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/*
******************************************************
* Copyright (c) 2018, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
*******************************************************
*/
#
include
<
arrayfire.h
>
#
include
<
gtest/gtest.h
>
#
include
<
testHelpers.hpp
>
#
include
<
af/data.h
>
#
include
<
af/dim4.hpp
>
#
include
<
af/traits.hpp
>
#
include
<
string
>
#
include
<
vector
>
using
std::abs;
using
std::string;
using
std::vector;
using
namespace
af
;
template
<
typename
T>
class
InverseDeconvolution
: public ::testing::Test {};
//
create a list of types to be tested
typedef
::testing::Types<
float
, schar, uchar,
short
, ushort> TestTypes;
//
register the type list
TYPED_TEST_SUITE
(InverseDeconvolution, TestTypes);
template
<
typename
T,
bool
isColor>
void
invDeconvImageTest
(string pTestFile,
const
float
gamma,
const
af_inverse_deconv_algo algo) {
typedef
typename
cond_type<is_same_type<T,
double
>::value,
double
,
float
>::type
OutType;
SUPPORTED_TYPE_CHECK
(T);
IMAGEIO_ENABLED_CHECK
();
using
af::dim4;
vector<dim4> inDims;
vector<string> inFiles;
vector<
dim_t
> outSizes;
vector<string> outFiles;
readImageTests
(pTestFile, inDims, inFiles, outSizes, outFiles);
size_t
testCount = inDims.
size
();
for
(
size_t
testId =
0
; testId < testCount; ++testId) {
inFiles[testId].
insert
(
0
,
string
(
TEST_DIR
"
/inverse_deconv/
"
));
outFiles[testId].
insert
(
0
,
string
(
TEST_DIR
"
/inverse_deconv/
"
));
af_array _inArray =
0
;
af_array inArray =
0
;
af_array kerArray =
0
;
af_array _outArray =
0
;
af_array cstArray =
0
;
af_array minArray =
0
;
af_array numArray =
0
;
af_array denArray =
0
;
af_array divArray =
0
;
af_array outArray =
0
;
af_array goldArray =
0
;
af_array _goldArray =
0
;
dim_t
nElems =
0
;
ASSERT_SUCCESS
(
af_gaussian_kernel
(&kerArray,
13
,
13
,
2.25
,
2.25
));
af_dtype otype = (af_dtype)af::dtype_traits<OutType>::af_type;
ASSERT_SUCCESS
(
af_load_image
(&_inArray, inFiles[testId].
c_str
(), isColor));
ASSERT_SUCCESS
(conv_image<T>(&inArray, _inArray));
ASSERT_SUCCESS
(
af_load_image
(&_goldArray, outFiles[testId].
c_str
(), isColor));
ASSERT_SUCCESS
(conv_image<OutType>(&goldArray, _goldArray));
ASSERT_SUCCESS
(
af_get_elements
(&nElems, goldArray));
unsigned
ndims;
dim_t
dims[
4
];
ASSERT_SUCCESS
(
af_get_numdims
(&ndims, goldArray));
ASSERT_SUCCESS
(
af_get_dims
(dims, dims +
1
, dims +
2
, dims +
3
, goldArray));
ASSERT_SUCCESS
(
af_inverse_deconv
(&_outArray, inArray, kerArray, gamma, algo));
double
maxima, minima, imag;
ASSERT_SUCCESS
(
af_min_all
(&minima, &imag, _outArray));
ASSERT_SUCCESS
(
af_max_all
(&maxima, &imag, _outArray));
ASSERT_SUCCESS
(
af_constant
(&cstArray,
255.0
, ndims, dims, otype));
ASSERT_SUCCESS
(
af_constant
(&denArray, (maxima - minima), ndims, dims, otype));
ASSERT_SUCCESS
(
af_constant
(&minArray, minima, ndims, dims, otype));
ASSERT_SUCCESS
(
af_sub
(&numArray, _outArray, minArray,
false
));
ASSERT_SUCCESS
(
af_div
(&divArray, numArray, denArray,
false
));
ASSERT_SUCCESS
(
af_mul
(&outArray, divArray, cstArray,
false
));
ASSERT_IMAGES_NEAR
(goldArray, outArray,
0.03
);
ASSERT_SUCCESS
(
af_release_array
(_inArray));
ASSERT_SUCCESS
(
af_release_array
(inArray));
ASSERT_SUCCESS
(
af_release_array
(kerArray));
ASSERT_SUCCESS
(
af_release_array
(cstArray));
ASSERT_SUCCESS
(
af_release_array
(minArray));
ASSERT_SUCCESS
(
af_release_array
(denArray));
ASSERT_SUCCESS
(
af_release_array
(numArray));
ASSERT_SUCCESS
(
af_release_array
(divArray));
ASSERT_SUCCESS
(
af_release_array
(_outArray));
ASSERT_SUCCESS
(
af_release_array
(outArray));
ASSERT_SUCCESS
(
af_release_array
(_goldArray));
ASSERT_SUCCESS
(
af_release_array
(goldArray));
}
}
TYPED_TEST
(InverseDeconvolution, TikhonovOnGrayscale) {
//
Test file name format: <colorspace>_<gamma with dots replaced by
//
"_">_<inverse deconv algo>.test
invDeconvImageTest<TypeParam,
false
>(
string
(
TEST_DIR
"
/inverse_deconv/gray_00_1_tikhonov.test
"
),
00
.
1f
,
AF_INVERSE_DECONV_TIKHONOV
);
}
TYPED_TEST
(InverseDeconvolution, DISABLED_WienerOnGrayscale) {
//
Test file name format: <colorspace>_<gamma with dots replaced by
//
"_">_<inverse deconv algo>.test
invDeconvImageTest<TypeParam,
false
>(
string
(
TEST_DIR
"
/inverse_deconv/gray_1_wiener.test
"
),
1.0
,
AF_INVERSE_DECONV_DEFAULT
);
//
TODO(pradeep) change to wiener enum value
}
Back
|
FazBrowse Home
|
New Git URL