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
41ffcc27
Commit
41ffcc27
authored
Mar 06, 2015
by
Erik Karlsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for h = 0.0
parent
1e82a67c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
+18
-12
fast_nlmeans_denoising_invoker_commons.hpp
modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp
+18
-12
No files found.
modules/photo/src/fast_nlmeans_denoising_invoker_commons.hpp
View file @
41ffcc27
...
@@ -126,11 +126,13 @@ class DistAbs
...
@@ -126,11 +126,13 @@ class DistAbs
{
{
static
inline
WT
f
(
double
dist
,
const
float
*
h
,
WT
fixed_point_mult
)
static
inline
WT
f
(
double
dist
,
const
float
*
h
,
WT
fixed_point_mult
)
{
{
double
w
=
std
::
exp
(
-
dist
*
dist
/
(
h
[
0
]
*
h
[
0
]
*
pixelInfo
<
T
>::
channels
));
if
(
std
::
isnan
(
w
))
w
=
1.0
;
// Handle h = 0.0
static
const
double
WEIGHT_THRESHOLD
=
0.001
;
static
const
double
WEIGHT_THRESHOLD
=
0.001
;
WT
weight
=
(
WT
)
round
(
fixed_point_mult
*
WT
weight
=
(
WT
)
round
(
fixed_point_mult
*
w
);
std
::
exp
(
-
dist
*
dist
/
(
h
[
0
]
*
h
[
0
]
*
pixelInfo
<
T
>::
channels
)));
if
(
weight
<
WEIGHT_THRESHOLD
*
fixed_point_mult
)
weight
=
0
;
if
(
weight
<
WEIGHT_THRESHOLD
*
fixed_point_mult
)
weight
=
0
;
return
weight
;
return
weight
;
}
}
};
};
...
@@ -167,7 +169,8 @@ public:
...
@@ -167,7 +169,8 @@ public:
};
};
template
<
typename
T
,
typename
WT
>
template
<
typename
T
,
typename
WT
>
static
inline
WT
calcWeight
(
double
dist
,
const
float
*
h
,
int
fixed_point_mult
)
static
inline
WT
calcWeight
(
double
dist
,
const
float
*
h
,
typename
pixelInfo
<
WT
>::
sampleType
fixed_point_mult
)
{
{
return
calcWeight_
<
T
,
WT
>::
f
(
dist
,
h
,
fixed_point_mult
);
return
calcWeight_
<
T
,
WT
>::
f
(
dist
,
h
,
fixed_point_mult
);
}
}
...
@@ -243,20 +246,22 @@ class DistSquared
...
@@ -243,20 +246,22 @@ class DistSquared
template
<
typename
T
,
typename
WT
>
struct
calcWeight_
template
<
typename
T
,
typename
WT
>
struct
calcWeight_
{
{
static
inline
WT
f
(
double
dist
,
const
float
*
h
,
int
fixed_point_mult
)
static
inline
WT
f
(
double
dist
,
const
float
*
h
,
WT
fixed_point_mult
)
{
{
double
w
=
std
::
exp
(
-
dist
/
(
h
[
0
]
*
h
[
0
]
*
pixelInfo
<
T
>::
channels
));
if
(
std
::
isnan
(
w
))
w
=
1.0
;
// Handle h = 0.0
static
const
double
WEIGHT_THRESHOLD
=
0.001
;
static
const
double
WEIGHT_THRESHOLD
=
0.001
;
WT
weight
=
(
WT
)
round
(
fixed_point_mult
*
WT
weight
=
(
WT
)
round
(
fixed_point_mult
*
w
);
std
::
exp
(
-
dist
/
(
h
[
0
]
*
h
[
0
]
*
pixelInfo
<
T
>::
channels
)));
if
(
weight
<
WEIGHT_THRESHOLD
*
fixed_point_mult
)
weight
=
0
;
if
(
weight
<
WEIGHT_THRESHOLD
*
fixed_point_mult
)
weight
=
0
;
return
weight
;
return
weight
;
}
}
};
};
template
<
typename
T
,
typename
ET
,
int
n
>
struct
calcWeight_
<
T
,
Vec
<
ET
,
n
>
>
template
<
typename
T
,
typename
ET
,
int
n
>
struct
calcWeight_
<
T
,
Vec
<
ET
,
n
>
>
{
{
static
inline
Vec
<
ET
,
n
>
f
(
double
dist
,
const
float
*
h
,
int
fixed_point_mult
)
static
inline
Vec
<
ET
,
n
>
f
(
double
dist
,
const
float
*
h
,
ET
fixed_point_mult
)
{
{
Vec
<
ET
,
n
>
res
;
Vec
<
ET
,
n
>
res
;
for
(
int
i
=
0
;
i
<
n
;
i
++
)
for
(
int
i
=
0
;
i
<
n
;
i
++
)
...
@@ -286,7 +291,8 @@ public:
...
@@ -286,7 +291,8 @@ public:
};
};
template
<
typename
T
,
typename
WT
>
template
<
typename
T
,
typename
WT
>
static
inline
WT
calcWeight
(
double
dist
,
const
float
*
h
,
int
fixed_point_mult
)
static
inline
WT
calcWeight
(
double
dist
,
const
float
*
h
,
typename
pixelInfo
<
WT
>::
sampleType
fixed_point_mult
)
{
{
return
calcWeight_
<
T
,
WT
>::
f
(
dist
,
h
,
fixed_point_mult
);
return
calcWeight_
<
T
,
WT
>::
f
(
dist
,
h
,
fixed_point_mult
);
}
}
...
...
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