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
18be52c0
Commit
18be52c0
authored
Mar 05, 2015
by
Erik Karlsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed LUTs from IT to int
parent
305cff36
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
26 deletions
+28
-26
fast_nlmeans_denoising_invoker.hpp
modules/photo/src/fast_nlmeans_denoising_invoker.hpp
+7
-6
fast_nlmeans_denoising_invoker_commons.hpp
modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp
+14
-14
fast_nlmeans_multi_denoising_invoker.hpp
modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp
+7
-6
No files found.
modules/photo/src/fast_nlmeans_denoising_invoker.hpp
View file @
18be52c0
...
...
@@ -75,9 +75,9 @@ private:
int
template_window_half_size_
;
int
search_window_half_size_
;
IT
fixed_point_mult_
;
int
fixed_point_mult_
;
int
almost_template_window_size_sq_bin_shift_
;
std
::
vector
<
IT
>
almost_dist2weight_
;
std
::
vector
<
int
>
almost_dist2weight_
;
void
calcDistSumsForFirstElementInRow
(
int
i
,
Array2d
<
int
>&
dist_sums
,
...
...
@@ -119,7 +119,8 @@ FastNlMeansDenoisingInvoker<T, IT, UIT, D>::FastNlMeansDenoisingInvoker(
const
IT
max_estimate_sum_value
=
(
IT
)
search_window_size_
*
(
IT
)
search_window_size_
*
(
IT
)
pixelInfo
<
T
>::
sampleMax
();
fixed_point_mult_
=
std
::
numeric_limits
<
IT
>::
max
()
/
max_estimate_sum_value
;
fixed_point_mult_
=
(
int
)
std
::
min
<
IT
>
(
std
::
numeric_limits
<
IT
>::
max
()
/
max_estimate_sum_value
,
std
::
numeric_limits
<
int
>::
max
());
// precalc weight for every possible l2 dist between blocks
// additional optimization of precalced weights to replace division(averaging) by binary shift
...
...
@@ -136,7 +137,7 @@ FastNlMeansDenoisingInvoker<T, IT, UIT, D>::FastNlMeansDenoisingInvoker(
for
(
int
almost_dist
=
0
;
almost_dist
<
almost_max_dist
;
almost_dist
++
)
{
double
dist
=
almost_dist
*
almost_dist2actual_dist_multiplier
;
IT
weight
=
(
IT
)
round
(
fixed_point_mult_
*
D
::
template
calcWeight
<
T
>
(
dist
,
h
));
int
weight
=
(
int
)
round
(
fixed_point_mult_
*
D
::
template
calcWeight
<
T
>
(
dist
,
h
));
if
(
weight
<
WEIGHT_THRESHOLD
*
fixed_point_mult_
)
weight
=
0
;
...
...
@@ -238,8 +239,8 @@ void FastNlMeansDenoisingInvoker<T, IT, UIT, D>::operator() (const Range& range)
for
(
int
x
=
0
;
x
<
search_window_size_
;
x
++
)
{
int
almostAvgDist
=
dist_sums_row
[
x
]
>>
almost_template_window_size_sq_bin_shift_
;
IT
weight
=
almost_dist2weight_
[
almostAvgDist
];
weights_sum
+=
weight
;
int
weight
=
almost_dist2weight_
[
almostAvgDist
];
weights_sum
+=
(
IT
)
weight
;
T
p
=
cur_row_ptr
[
border_size_
+
search_window_x
+
x
];
incWithWeight
<
T
,
IT
>
(
estimation
,
weight
,
p
);
...
...
modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp
View file @
18be52c0
...
...
@@ -253,39 +253,39 @@ public:
template
<
typename
T
,
typename
IT
>
struct
incWithWeight_
{
static
inline
void
f
(
IT
*
estimation
,
IT
weight
,
T
p
)
static
inline
void
f
(
IT
*
estimation
,
int
weight
,
T
p
)
{
estimation
[
0
]
+=
weight
*
p
;
estimation
[
0
]
+=
(
IT
)
weight
*
p
;
}
};
template
<
typename
ET
,
typename
IT
>
struct
incWithWeight_
<
Vec
<
ET
,
2
>
,
IT
>
{
static
inline
void
f
(
IT
*
estimation
,
IT
weight
,
Vec
<
ET
,
2
>
p
)
static
inline
void
f
(
IT
*
estimation
,
int
weight
,
Vec
<
ET
,
2
>
p
)
{
estimation
[
0
]
+=
weight
*
p
[
0
];
estimation
[
1
]
+=
weight
*
p
[
1
];
estimation
[
0
]
+=
(
IT
)
weight
*
p
[
0
];
estimation
[
1
]
+=
(
IT
)
weight
*
p
[
1
];
}
};
template
<
typename
ET
,
typename
IT
>
struct
incWithWeight_
<
Vec
<
ET
,
3
>
,
IT
>
{
static
inline
void
f
(
IT
*
estimation
,
IT
weight
,
Vec
<
ET
,
3
>
p
)
static
inline
void
f
(
IT
*
estimation
,
int
weight
,
Vec
<
ET
,
3
>
p
)
{
estimation
[
0
]
+=
weight
*
p
[
0
];
estimation
[
1
]
+=
weight
*
p
[
1
];
estimation
[
2
]
+=
weight
*
p
[
2
];
estimation
[
0
]
+=
(
IT
)
weight
*
p
[
0
];
estimation
[
1
]
+=
(
IT
)
weight
*
p
[
1
];
estimation
[
2
]
+=
(
IT
)
weight
*
p
[
2
];
}
};
template
<
typename
ET
,
typename
IT
>
struct
incWithWeight_
<
Vec
<
ET
,
4
>
,
IT
>
{
static
inline
void
f
(
IT
*
estimation
,
IT
weight
,
Vec
<
ET
,
4
>
p
)
static
inline
void
f
(
IT
*
estimation
,
int
weight
,
Vec
<
ET
,
4
>
p
)
{
estimation
[
0
]
+=
weight
*
p
[
0
];
estimation
[
1
]
+=
weight
*
p
[
1
];
estimation
[
2
]
+=
weight
*
p
[
2
];
estimation
[
3
]
+=
weight
*
p
[
3
];
estimation
[
0
]
+=
(
IT
)
weight
*
p
[
0
];
estimation
[
1
]
+=
(
IT
)
weight
*
p
[
1
];
estimation
[
2
]
+=
(
IT
)
weight
*
p
[
2
];
estimation
[
3
]
+=
(
IT
)
weight
*
p
[
3
];
}
};
...
...
modules/photo/src/fast_nlmeans_multi_denoising_invoker.hpp
View file @
18be52c0
...
...
@@ -81,9 +81,9 @@ private:
int
search_window_half_size_
;
int
temporal_window_half_size_
;
IT
fixed_point_mult_
;
int
fixed_point_mult_
;
int
almost_template_window_size_sq_bin_shift
;
std
::
vector
<
IT
>
almost_dist2weight
;
std
::
vector
<
int
>
almost_dist2weight
;
void
calcDistSumsForFirstElementInRow
(
int
i
,
Array3d
<
int
>&
dist_sums
,
Array4d
<
int
>&
col_dist_sums
,
...
...
@@ -127,7 +127,8 @@ FastNlMeansMultiDenoisingInvoker<T, IT, UIT, D>::FastNlMeansMultiDenoisingInvoke
main_extended_src_
=
extended_srcs_
[
temporal_window_half_size_
];
const
IT
max_estimate_sum_value
=
(
IT
)
temporal_window_size_
*
(
IT
)
search_window_size_
*
(
IT
)
search_window_size_
*
(
IT
)
pixelInfo
<
T
>::
sampleMax
();
fixed_point_mult_
=
std
::
numeric_limits
<
IT
>::
max
()
/
max_estimate_sum_value
;
fixed_point_mult_
=
(
int
)
std
::
min
<
IT
>
(
std
::
numeric_limits
<
IT
>::
max
()
/
max_estimate_sum_value
,
std
::
numeric_limits
<
int
>::
max
());
// precalc weight for every possible l2 dist between blocks
// additional optimization of precalced weights to replace division(averaging) by binary shift
...
...
@@ -147,7 +148,7 @@ FastNlMeansMultiDenoisingInvoker<T, IT, UIT, D>::FastNlMeansMultiDenoisingInvoke
for
(
int
almost_dist
=
0
;
almost_dist
<
almost_max_dist
;
almost_dist
++
)
{
double
dist
=
almost_dist
*
almost_dist2actual_dist_multiplier
;
IT
weight
=
(
IT
)
round
(
fixed_point_mult_
*
D
::
template
calcWeight
<
T
>
(
dist
,
h
));
int
weight
=
(
int
)
round
(
fixed_point_mult_
*
D
::
template
calcWeight
<
T
>
(
dist
,
h
));
if
(
weight
<
WEIGHT_THRESHOLD
*
fixed_point_mult_
)
weight
=
0
;
...
...
@@ -266,8 +267,8 @@ void FastNlMeansMultiDenoisingInvoker<T, IT, UIT, D>::operator() (const Range& r
{
int
almostAvgDist
=
dist_sums_row
[
x
]
>>
almost_template_window_size_sq_bin_shift
;
IT
weight
=
almost_dist2weight
[
almostAvgDist
];
weights_sum
+=
weight
;
int
weight
=
almost_dist2weight
[
almostAvgDist
];
weights_sum
+=
(
IT
)
weight
;
T
p
=
cur_row_ptr
[
border_size_
+
search_window_x
+
x
];
incWithWeight
<
T
,
IT
>
(
estimation
,
weight
,
p
);
...
...
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