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
7faf1f62
Commit
7faf1f62
authored
Feb 18, 2014
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some improvements
parent
72c327fe
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
11 deletions
+23
-11
perf_denoising.cpp
modules/photo/perf/opencl/perf_denoising.cpp
+1
-1
fast_nlmeans_denoising_opencl.hpp
modules/photo/src/fast_nlmeans_denoising_opencl.hpp
+1
-1
nlmeans.cl
modules/photo/src/opencl/nlmeans.cl
+21
-9
No files found.
modules/photo/perf/opencl/perf_denoising.cpp
View file @
7faf1f62
...
...
@@ -26,7 +26,7 @@ OCL_PERF_TEST(Photo, DenoisingGrayscale)
OCL_TEST_CYCLE
()
cv
::
fastNlMeansDenoising
(
original
,
result
,
10
);
SANITY_CHECK
(
result
);
SANITY_CHECK
(
result
,
1
);
}
OCL_PERF_TEST
(
Photo
,
DenoisingColored
)
...
...
modules/photo/src/fast_nlmeans_denoising_opencl.hpp
View file @
7faf1f62
...
...
@@ -19,7 +19,7 @@ enum
{
BLOCK_ROWS
=
32
,
BLOCK_COLS
=
128
,
CTA_SIZE
=
128
CTA_SIZE
=
256
};
static
inline
int
getNearestPowerOf2
(
int
value
)
...
...
modules/photo/src/opencl/nlmeans.cl
View file @
7faf1f62
...
...
@@ -35,8 +35,6 @@ __kernel void calcAlmostDist2Weight(__global int * almostDist2Weight, int almost
weight
=
0
;
almostDist2Weight[almostDist]
=
weight
;
//
printf
(
"%d "
,
weight
)
;
}
}
...
...
@@ -50,12 +48,20 @@ inline int_t calcDist(uchar_t a, uchar_t b)
return
diff
*
diff
;
}
inline
int_t
calcDistUpDown
(
uchar_t
down_value,
uchar_t
down_value_t,
uchar_t
up_value,
uchar_t
up_value_t
)
{
int_t
A
=
convert_int_t
(
down_value
)
-
convert_int_t
(
down_value_t
)
;
int_t
B
=
convert_int_t
(
up_value
)
-
convert_int_t
(
up_value_t
)
;
return
(
A
-
B
)
*
(
A
+
B
)
;
}
inline
void
calcFirstElementInRow
(
__global
const
uchar
*
src,
int
src_step,
int
src_offset,
__local
int_t
*
dists,
int
y,
int
x,
int
id,
__global
int_t
*
col_dists,
__global
int_t
*
up_col_dists
)
{
y
-=
TEMPLATE_SIZE2
;
int
sx
=
x
-
SEARCH_SIZE2,
sy
=
y
-
SEARCH_SIZE2
;
int_t
col_dists_current_private[TEMPLATE_SIZE]
;
for
(
int
i
=
id,
size
=
SEARCH_SIZE_SQ
; i < size; i += CTA_SIZE)
{
...
...
@@ -68,9 +74,8 @@ inline void calcFirstElementInRow(__global const uchar * src, int src_step, int
#
pragma
unroll
for
(
int
j
=
0
; j < TEMPLATE_SIZE; ++j)
col_dists_current[j]
=
(
int_t
)(
0
)
;
col_dists_current
_private
[j]
=
(
int_t
)(
0
)
;
#
pragma
unroll
for
(
int
ty
=
0
; ty < TEMPLATE_SIZE; ++ty)
{
#
pragma
unroll
...
...
@@ -78,7 +83,7 @@ inline void calcFirstElementInRow(__global const uchar * src, int src_step, int
{
value
=
calcDist
(
src_template[tx],
src_current[tx]
)
;
col_dists_current[tx
+
TEMPLATE_SIZE2]
+=
value
;
col_dists_current
_private
[tx
+
TEMPLATE_SIZE2]
+=
value
;
dist
+=
value
;
}
...
...
@@ -86,6 +91,10 @@ inline void calcFirstElementInRow(__global const uchar * src, int src_step, int
src_template
=
(
__global
const
uchar_t
*
)((
__global
const
uchar
*
)
src_template
+
src_step
)
;
}
#
pragma
unroll
for
(
int
j
=
0
; j < TEMPLATE_SIZE; ++j)
col_dists_current[j]
=
col_dists_current_private[j]
;
dists[i]
=
dist
;
up_col_dists[0
+
i]
=
col_dists[TEMPLATE_SIZE
-
1]
;
}
...
...
@@ -148,7 +157,7 @@ inline void calcElement(__global const uchar * src, int src_step, int src_offset
__global
int_t
*
col_dists_current
=
col_dists
+
mad24
(
i,
TEMPLATE_SIZE,
first
)
;
__global
int_t
*
up_col_dists_current
=
up_col_dists
+
mad24
(
x0,
SEARCH_SIZE_SQ,
i
)
;
int_t
col_dist
=
up_col_dists_current[0]
+
calcDist
(
down_value,
down_value_t
)
-
calcDist
(
up_value,
up_value_t
)
;
int_t
col_dist
=
up_col_dists_current[0]
+
calcDist
UpDown
(
down_value,
down_value_t,
up_value,
up_value_t
)
;
dists[i]
+=
col_dist
-
col_dists_current[0]
;
col_dists_current[0]
=
col_dist
;
...
...
@@ -192,7 +201,7 @@ inline void convolveWindow(__global const uchar * src, int src_step, int src_off
}
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
for
(
int
lsize
=
CTA_SIZE2
>>
1
; lsize >
0
; lsize >>= 1)
for
(
int
lsize
=
CTA_SIZE2
>>
1
; lsize >
2
; lsize >>= 1)
{
if
(
id
<
lsize
)
{
...
...
@@ -206,7 +215,11 @@ inline void convolveWindow(__global const uchar * src, int src_step, int src_off
if
(
id
==
0
)
{
int
dst_index
=
mad24
(
y,
dst_step,
mad24
(
cn,
x,
dst_offset
))
;
*
(
__global
uchar_t
*
)(
dst
+
dst_index
)
=
convert_uchar_t
(
weighted_sum_local[0]
/
weights_local[0]
)
;
int_t
weighted_sum_local_0
=
weighted_sum_local[0]
+
weighted_sum_local[1]
+
weighted_sum_local[2]
+
weighted_sum_local[3]
;
int
weights_local_0
=
weights_local[0]
+
weights_local[1]
+
weights_local[2]
+
weights_local[3]
;
*
(
__global
uchar_t
*
)(
dst
+
dst_index
)
=
convert_uchar_t
(
weighted_sum_local_0
/
weights_local_0
)
;
}
}
...
...
@@ -234,7 +247,6 @@ __kernel void fastNlMeansDenoising(__global const uchar * src, int src_step, int
for
(
int
y
=
y0
; y < y1; ++y)
for
(
int
x
=
x0
; x < x1; ++x)
{
//
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
if
(
x
==
x0
)
{
calcFirstElementInRow
(
src,
src_step,
src_offset,
dists,
y,
x,
id,
col_dists,
up_col_dists
)
;
...
...
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