Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
baf266c2
Commit
baf266c2
authored
Feb 17, 2015
by
Erik Karlsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed from sum of squared differences to sum of abs differences
parent
c339720a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
34 deletions
+8
-34
fast_nlmeans_denoising_invoker.hpp
modules/photo/src/fast_nlmeans_denoising_invoker.hpp
+2
-3
fast_nlmeans_denoising_invoker_commons.hpp
modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp
+4
-28
fast_nlmeans_multi_denoising_invoker.hpp
modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp
+2
-3
No files found.
modules/photo/src/fast_nlmeans_denoising_invoker.hpp
View file @
baf266c2
...
...
@@ -130,13 +130,12 @@ FastNlMeansDenoisingInvoker<T, IT, UIT>::FastNlMeansDenoisingInvoker(
const
double
WEIGHT_THRESHOLD
=
0.001
;
const
size_t
ALLOC_CHUNK
=
65536
;
IT
max_dist
=
(
IT
)
pixelInfo
<
T
>::
sampleMax
()
*
(
IT
)
pixelInfo
<
T
>::
sampleMax
()
*
(
IT
)
pixelInfo
<
T
>::
channels
;
IT
max_dist
=
(
IT
)
pixelInfo
<
T
>::
sampleMax
()
*
(
IT
)
pixelInfo
<
T
>::
channels
;
size_t
almost_max_dist
=
0
;
while
(
true
)
{
double
dist
=
almost_max_dist
*
almost_dist2actual_dist_multiplier
;
IT
weight
=
(
IT
)
round
(
fixed_point_mult_
*
std
::
exp
(
-
dist
/
(
h
*
h
*
pixelInfo
<
T
>::
channels
)));
IT
weight
=
(
IT
)
round
(
fixed_point_mult_
*
std
::
exp
(
-
dist
*
dist
/
(
h
*
h
*
pixelInfo
<
T
>::
channels
)));
if
(
weight
<
WEIGHT_THRESHOLD
*
fixed_point_mult_
||
dist
>
max_dist
)
break
;
if
(
almost_max_dist
>=
almost_dist2weight_
.
size
())
...
...
modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp
View file @
baf266c2
...
...
@@ -85,7 +85,7 @@ template <typename T, typename IT> struct calcDist_
{
static
inline
IT
f
(
const
T
a
,
const
T
b
)
{
return
(
IT
)(
a
-
b
)
*
(
IT
)(
a
-
b
);
return
std
::
abs
((
IT
)(
a
-
b
)
);
}
};
...
...
@@ -93,7 +93,7 @@ template <typename ET, typename IT> struct calcDist_<Vec<ET, 2>, IT>
{
static
inline
IT
f
(
const
Vec
<
ET
,
2
>
a
,
const
Vec
<
ET
,
2
>
b
)
{
return
(
IT
)(
a
[
0
]
-
b
[
0
])
*
(
IT
)(
a
[
0
]
-
b
[
0
])
+
(
IT
)(
a
[
1
]
-
b
[
1
])
*
(
IT
)(
a
[
1
]
-
b
[
1
]
);
return
std
::
abs
((
IT
)(
a
[
0
]
-
b
[
0
]))
+
std
::
abs
((
IT
)(
a
[
1
]
-
b
[
1
])
);
}
};
...
...
@@ -101,10 +101,7 @@ template <typename ET, typename IT> struct calcDist_<Vec<ET, 3>, IT>
{
static
inline
IT
f
(
const
Vec
<
ET
,
3
>
a
,
const
Vec
<
ET
,
3
>
b
)
{
return
(
IT
)(
a
[
0
]
-
b
[
0
])
*
(
IT
)(
a
[
0
]
-
b
[
0
])
+
(
IT
)(
a
[
1
]
-
b
[
1
])
*
(
IT
)(
a
[
1
]
-
b
[
1
])
+
(
IT
)(
a
[
2
]
-
b
[
2
])
*
(
IT
)(
a
[
2
]
-
b
[
2
]);
return
std
::
abs
((
IT
)(
a
[
0
]
-
b
[
0
]))
+
std
::
abs
((
IT
)(
a
[
1
]
-
b
[
1
]))
+
std
::
abs
((
IT
)(
a
[
2
]
-
b
[
2
]));
}
};
...
...
@@ -121,31 +118,10 @@ static inline IT calcDist(const Mat& m, int i1, int j1, int i2, int j2)
return
calcDist
<
T
,
IT
>
(
a
,
b
);
}
template
<
typename
T
,
typename
IT
>
struct
calcUpDownDist_
{
static
inline
IT
f
(
T
a_up
,
T
a_down
,
T
b_up
,
T
b_down
)
{
IT
A
=
a_down
-
b_down
;
IT
B
=
a_up
-
b_up
;
return
(
A
-
B
)
*
(
A
+
B
);
}
};
template
<
typename
ET
,
int
n
,
typename
IT
>
struct
calcUpDownDist_
<
Vec
<
ET
,
n
>
,
IT
>
{
private
:
typedef
Vec
<
ET
,
n
>
T
;
public
:
static
inline
IT
f
(
T
a_up
,
T
a_down
,
T
b_up
,
T
b_down
)
{
return
calcDist
<
T
,
IT
>
(
a_down
,
b_down
)
-
calcDist
<
T
,
IT
>
(
a_up
,
b_up
);
}
};
template
<
typename
T
,
typename
IT
>
static
inline
IT
calcUpDownDist
(
T
a_up
,
T
a_down
,
T
b_up
,
T
b_down
)
{
return
calc
UpDownDist_
<
T
,
IT
>::
f
(
a_up
,
a_down
,
b_up
,
b_down
);
return
calc
Dist
<
T
,
IT
>
(
a_down
,
b_down
)
-
calcDist
<
T
,
IT
>
(
a_up
,
b_up
);
};
template
<
typename
T
,
typename
IT
>
struct
incWithWeight_
...
...
modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp
View file @
baf266c2
...
...
@@ -141,13 +141,12 @@ FastNlMeansMultiDenoisingInvoker<T, IT, UIT>::FastNlMeansMultiDenoisingInvoker(
const
double
WEIGHT_THRESHOLD
=
0.001
;
const
size_t
ALLOC_CHUNK
=
65536
;
IT
max_dist
=
(
IT
)
pixelInfo
<
T
>::
sampleMax
()
*
(
IT
)
pixelInfo
<
T
>::
sampleMax
()
*
(
IT
)
pixelInfo
<
T
>::
channels
;
IT
max_dist
=
(
IT
)
pixelInfo
<
T
>::
sampleMax
()
*
(
IT
)
pixelInfo
<
T
>::
channels
;
size_t
almost_max_dist
=
0
;
while
(
true
)
{
double
dist
=
almost_max_dist
*
almost_dist2actual_dist_multiplier
;
IT
weight
=
(
IT
)
round
(
fixed_point_mult_
*
std
::
exp
(
-
dist
/
(
h
*
h
*
pixelInfo
<
T
>::
channels
)));
IT
weight
=
(
IT
)
round
(
fixed_point_mult_
*
std
::
exp
(
-
dist
*
dist
/
(
h
*
h
*
pixelInfo
<
T
>::
channels
)));
if
(
weight
<
WEIGHT_THRESHOLD
*
fixed_point_mult_
||
dist
>
max_dist
)
break
;
if
(
almost_max_dist
>=
almost_dist2weight
.
size
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment