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
01d3df0d
Commit
01d3df0d
authored
Mar 24, 2015
by
Erik Karlsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added normType parameter to fastNlMeansDenoisingMulti
parent
70a64ebe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
37 deletions
+92
-37
photo.hpp
modules/photo/include/opencv2/photo.hpp
+11
-7
denoising.cpp
modules/photo/src/denoising.cpp
+81
-30
No files found.
modules/photo/include/opencv2/photo.hpp
View file @
01d3df0d
...
...
@@ -142,7 +142,8 @@ CV_EXPORTS_W void fastNlMeansDenoising( InputArray src, OutputArray dst, float h
<http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
optimizations. Noise expected to be a gaussian white noise
@param src Input 8-bit 1-channel, 2-channel, 3-channel or 4-channel image.
@param src Input 8-bit or 16-bit (only with NORM_L1) 1-channel,
2-channel, 3-channel or 4-channel image.
@param dst Output image with the same size and type as src .
@param templateWindowSize Size in pixels of the template patch that is used to compute weights.
Should be odd. Recommended value 7 pixels
...
...
@@ -153,7 +154,7 @@ denoising time. Recommended value 21 pixels
parameter applied to all channels or one per channel in dst. Big h value
perfectly removes noise but also removes image details, smaller h
value preserves details but also preserves some noise
@param normType Type of norm used for weight calc
lu
ation. Can be either NORM_L2 or NORM_L1
@param normType Type of norm used for weight calc
ul
ation. Can be either NORM_L2 or NORM_L1
This function expected to be applied to grayscale images. For colored images look at
fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored
...
...
@@ -220,9 +221,9 @@ captured in small period of time. For example video. This version of the functio
images or for manual manipulation with colorspaces. For more details see
<http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.131.6394>
@param srcImgs Input 8-bit
1-channel, 2-channel, 3-channel or
4-channel images sequence. All images should have the same type an
d
size.
@param srcImgs Input 8-bit
or 16-bit (only with NORM_L1) 1-channel,
2-channel, 3-channel or 4-channel images sequence. All images shoul
d
have the same type and
size.
@param imgToDenoiseIndex Target image to denoise index in srcImgs sequence
@param temporalWindowSize Number of surrounding images to use for target image denoising. Should
be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
...
...
@@ -238,10 +239,13 @@ denoising time. Recommended value 21 pixels
parameter applied to all channels or one per channel in dst. Big h value
perfectly removes noise but also removes image details, smaller h
value preserves details but also preserves some noise
@param normType Type of norm used for weight calculation. Can be either NORM_L2 or NORM_L1
*/
CV_EXPORTS_W
void
fastNlMeansDenoisingMulti
(
InputArrayOfArrays
srcImgs
,
OutputArray
dst
,
int
imgToDenoiseIndex
,
int
temporalWindowSize
,
const
std
::
vector
<
float
>&
h
,
int
templateWindowSize
=
7
,
int
searchWindowSize
=
21
);
int
imgToDenoiseIndex
,
int
temporalWindowSize
,
const
std
::
vector
<
float
>&
h
,
int
templateWindowSize
=
7
,
int
searchWindowSize
=
21
,
int
normType
=
NORM_L2
);
/** @brief Modification of fastNlMeansDenoisingMulti function for colored images sequences
...
...
modules/photo/src/denoising.cpp
View file @
01d3df0d
...
...
@@ -230,73 +230,55 @@ static void fastNlMeansDenoisingMultiCheckPreconditions(
}
}
void
cv
::
fastNlMeansDenoisingMulti
(
InputArrayOfArrays
_srcImgs
,
OutputArray
_dst
,
int
imgToDenoiseIndex
,
int
temporalWindowSize
,
float
h
,
int
templateWindowSize
,
int
searchWindowSize
)
{
fastNlMeansDenoisingMulti
(
_srcImgs
,
_dst
,
imgToDenoiseIndex
,
temporalWindowSize
,
std
::
vector
<
float
>
(
1
,
h
),
templateWindowSize
,
searchWindowSize
);
}
void
cv
::
fastNlMeansDenoisingMulti
(
InputArrayOfArrays
_srcImgs
,
OutputArray
_dst
,
int
imgToDenoiseIndex
,
int
temporalWindowSize
,
const
std
::
vector
<
float
>&
h
,
int
templateWindowSize
,
int
searchWindowSize
)
template
<
typename
ST
,
typename
IT
,
typename
UIT
,
typename
D
>
static
void
fastNlMeansDenoisingMulti_
(
const
std
::
vector
<
Mat
>&
srcImgs
,
Mat
&
dst
,
int
imgToDenoiseIndex
,
int
temporalWindowSize
,
const
std
::
vector
<
float
>&
h
,
int
templateWindowSize
,
int
searchWindowSize
)
{
std
::
vector
<
Mat
>
srcImgs
;
_srcImgs
.
getMatVector
(
srcImgs
);
fastNlMeansDenoisingMultiCheckPreconditions
(
srcImgs
,
imgToDenoiseIndex
,
temporalWindowSize
,
templateWindowSize
,
searchWindowSize
);
int
hn
=
(
int
)
h
.
size
();
CV_Assert
(
hn
==
1
||
hn
==
CV_MAT_CN
(
srcImgs
[
0
].
type
()));
_dst
.
create
(
srcImgs
[
0
].
size
(),
srcImgs
[
0
].
type
());
Mat
dst
=
_dst
.
getMat
();
switch
(
srcImgs
[
0
].
type
())
{
case
CV_8U
:
parallel_for_
(
cv
::
Range
(
0
,
srcImgs
[
0
].
rows
),
FastNlMeansMultiDenoisingInvoker
<
uchar
,
int
,
unsigned
,
DistSquared
,
int
>
(
FastNlMeansMultiDenoisingInvoker
<
uchar
,
IT
,
UIT
,
D
,
int
>
(
srcImgs
,
imgToDenoiseIndex
,
temporalWindowSize
,
dst
,
templateWindowSize
,
searchWindowSize
,
&
h
[
0
]));
break
;
case
CV_8UC2
:
if
(
hn
==
1
)
parallel_for_
(
cv
::
Range
(
0
,
srcImgs
[
0
].
rows
),
FastNlMeansMultiDenoisingInvoker
<
Vec
2b
,
int
,
unsigned
,
DistSquared
,
int
>
(
FastNlMeansMultiDenoisingInvoker
<
Vec
<
ST
,
2
>
,
IT
,
UIT
,
D
,
int
>
(
srcImgs
,
imgToDenoiseIndex
,
temporalWindowSize
,
dst
,
templateWindowSize
,
searchWindowSize
,
&
h
[
0
]));
else
parallel_for_
(
cv
::
Range
(
0
,
srcImgs
[
0
].
rows
),
FastNlMeansMultiDenoisingInvoker
<
Vec
2b
,
int
,
unsigned
,
DistSquared
,
Vec2i
>
(
FastNlMeansMultiDenoisingInvoker
<
Vec
<
ST
,
2
>
,
IT
,
UIT
,
D
,
Vec2i
>
(
srcImgs
,
imgToDenoiseIndex
,
temporalWindowSize
,
dst
,
templateWindowSize
,
searchWindowSize
,
&
h
[
0
]));
break
;
case
CV_8UC3
:
if
(
hn
==
1
)
parallel_for_
(
cv
::
Range
(
0
,
srcImgs
[
0
].
rows
),
FastNlMeansMultiDenoisingInvoker
<
Vec
3b
,
int
,
unsigned
,
DistSquared
,
int
>
(
FastNlMeansMultiDenoisingInvoker
<
Vec
<
ST
,
3
>
,
IT
,
UIT
,
D
,
int
>
(
srcImgs
,
imgToDenoiseIndex
,
temporalWindowSize
,
dst
,
templateWindowSize
,
searchWindowSize
,
&
h
[
0
]));
else
parallel_for_
(
cv
::
Range
(
0
,
srcImgs
[
0
].
rows
),
FastNlMeansMultiDenoisingInvoker
<
Vec
3b
,
int
,
unsigned
,
DistSquared
,
Vec3i
>
(
FastNlMeansMultiDenoisingInvoker
<
Vec
<
ST
,
3
>
,
IT
,
UIT
,
D
,
Vec3i
>
(
srcImgs
,
imgToDenoiseIndex
,
temporalWindowSize
,
dst
,
templateWindowSize
,
searchWindowSize
,
&
h
[
0
]));
break
;
case
CV_8UC4
:
if
(
hn
==
1
)
parallel_for_
(
cv
::
Range
(
0
,
srcImgs
[
0
].
rows
),
FastNlMeansMultiDenoisingInvoker
<
Vec
4b
,
int
,
unsigned
,
DistSquared
,
int
>
(
FastNlMeansMultiDenoisingInvoker
<
Vec
<
ST
,
4
>
,
IT
,
UIT
,
D
,
int
>
(
srcImgs
,
imgToDenoiseIndex
,
temporalWindowSize
,
dst
,
templateWindowSize
,
searchWindowSize
,
&
h
[
0
]));
else
parallel_for_
(
cv
::
Range
(
0
,
srcImgs
[
0
].
rows
),
FastNlMeansMultiDenoisingInvoker
<
Vec
4b
,
int
,
unsigned
,
DistSquared
,
Vec4i
>
(
FastNlMeansMultiDenoisingInvoker
<
Vec
<
ST
,
4
>
,
IT
,
UIT
,
D
,
Vec4i
>
(
srcImgs
,
imgToDenoiseIndex
,
temporalWindowSize
,
dst
,
templateWindowSize
,
searchWindowSize
,
&
h
[
0
]));
break
;
...
...
@@ -306,6 +288,75 @@ void cv::fastNlMeansDenoisingMulti( InputArrayOfArrays _srcImgs, OutputArray _ds
}
}
void
cv
::
fastNlMeansDenoisingMulti
(
InputArrayOfArrays
_srcImgs
,
OutputArray
_dst
,
int
imgToDenoiseIndex
,
int
temporalWindowSize
,
float
h
,
int
templateWindowSize
,
int
searchWindowSize
)
{
fastNlMeansDenoisingMulti
(
_srcImgs
,
_dst
,
imgToDenoiseIndex
,
temporalWindowSize
,
std
::
vector
<
float
>
(
1
,
h
),
templateWindowSize
,
searchWindowSize
);
}
void
cv
::
fastNlMeansDenoisingMulti
(
InputArrayOfArrays
_srcImgs
,
OutputArray
_dst
,
int
imgToDenoiseIndex
,
int
temporalWindowSize
,
const
std
::
vector
<
float
>&
h
,
int
templateWindowSize
,
int
searchWindowSize
,
int
normType
)
{
std
::
vector
<
Mat
>
srcImgs
;
_srcImgs
.
getMatVector
(
srcImgs
);
fastNlMeansDenoisingMultiCheckPreconditions
(
srcImgs
,
imgToDenoiseIndex
,
temporalWindowSize
,
templateWindowSize
,
searchWindowSize
);
int
hn
=
(
int
)
h
.
size
();
int
type
=
srcImgs
[
0
].
type
(),
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
);
CV_Assert
(
hn
==
1
||
hn
==
cn
);
_dst
.
create
(
srcImgs
[
0
].
size
(),
srcImgs
[
0
].
type
());
Mat
dst
=
_dst
.
getMat
();
switch
(
normType
)
{
case
NORM_L2
:
switch
(
depth
)
{
case
CV_8U
:
fastNlMeansDenoisingMulti_
<
uchar
,
int
,
unsigned
,
DistSquared
>
(
srcImgs
,
dst
,
imgToDenoiseIndex
,
temporalWindowSize
,
h
,
templateWindowSize
,
searchWindowSize
);
break
;
default
:
CV_Error
(
Error
::
StsBadArg
,
"Unsupported depth! Only CV_8U is supported for NORM_L2"
);
}
break
;
case
NORM_L1
:
switch
(
depth
)
{
case
CV_8U
:
fastNlMeansDenoisingMulti_
<
uchar
,
int
,
unsigned
,
DistAbs
>
(
srcImgs
,
dst
,
imgToDenoiseIndex
,
temporalWindowSize
,
h
,
templateWindowSize
,
searchWindowSize
);
break
;
case
CV_16U
:
fastNlMeansDenoisingMulti_
<
ushort
,
int64
,
uint64
,
DistAbs
>
(
srcImgs
,
dst
,
imgToDenoiseIndex
,
temporalWindowSize
,
h
,
templateWindowSize
,
searchWindowSize
);
break
;
default
:
CV_Error
(
Error
::
StsBadArg
,
"Unsupported depth! Only CV_8U and CV_16U are supported for NORM_L1"
);
}
break
;
default
:
CV_Error
(
Error
::
StsBadArg
,
"Unsupported norm type! Only NORM_L2 and NORM_L1 are supported"
);
}
}
void
cv
::
fastNlMeansDenoisingColoredMulti
(
InputArrayOfArrays
_srcImgs
,
OutputArray
_dst
,
int
imgToDenoiseIndex
,
int
temporalWindowSize
,
float
h
,
float
hForColorComponents
,
...
...
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