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
b449b0bf
Commit
b449b0bf
authored
Mar 19, 2014
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplified cv::sepFilter2D OpenCL part
parent
82e6edfb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
47 deletions
+30
-47
filter.cpp
modules/imgproc/src/filter.cpp
+0
-0
filterSepCol.cl
modules/imgproc/src/opencl/filterSepCol.cl
+22
-40
filterSepRow.cl
modules/imgproc/src/opencl/filterSepRow.cl
+0
-0
filterSep_singlePass.cl
modules/imgproc/src/opencl/filterSep_singlePass.cl
+5
-6
test_sepfilter2D.cpp
modules/imgproc/test/ocl/test_sepfilter2D.cpp
+3
-1
No files found.
modules/imgproc/src/filter.cpp
View file @
b449b0bf
This diff is collapsed.
Click to expand it.
modules/imgproc/src/opencl/filterSepCol.cl
View file @
b449b0bf
...
...
@@ -36,16 +36,6 @@
#
define
READ_TIMES_COL
((
2*
(
RADIUSY+LSIZE1
)
-1
)
/LSIZE1
)
#
define
RADIUS
1
#
if
CN
==1
#
define
ALIGN
(((
RADIUS
)
+3
)
>>2<<2
)
#
elif
CN==2
#
define
ALIGN
(((
RADIUS
)
+1
)
>>1<<1
)
#
elif
CN==3
#
define
ALIGN
(((
RADIUS
)
+3
)
>>2<<2
)
#
elif
CN==4
#
define
ALIGN
(
RADIUS
)
#
define
READ_TIMES_ROW
((
2*
(
RADIUS+LSIZE0
)
-1
)
/LSIZE0
)
#
endif
#
define
noconvert
...
...
@@ -65,16 +55,8 @@ The info above maybe obsolete.
#
define
DIG
(
a
)
a,
__constant
float
mat_kernel[]
=
{
COEFF
}
;
__kernel
__attribute__
((
reqd_work_group_size
(
LSIZE0,LSIZE1,1
)))
void
col_filter
(
__global
const
GENTYPE_SRC
*
restrict
src,
const
int
src_step_in_pixel,
const
int
src_whole_cols,
const
int
src_whole_rows,
__global
GENTYPE_DST
*
dst,
const
int
dst_offset_in_pixel,
const
int
dst_step_in_pixel,
const
int
dst_cols,
const
int
dst_rows
)
__kernel
void
col_filter
(
__global
const
srcT
*
src,
int
src_step_in_pixel,
int
src_whole_cols,
int
src_whole_rows,
__global
dstT
*
dst,
int
dst_offset_in_pixel,
int
dst_step_in_pixel,
int
dst_cols,
int
dst_rows
)
{
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
...
...
@@ -85,35 +67,35 @@ __kernel __attribute__((reqd_work_group_size(LSIZE0,LSIZE1,1))) void col_filter
int
start_addr
=
mad24
(
y,
src_step_in_pixel,
x
)
;
int
end_addr
=
mad24
(
src_whole_rows
-
1
,
src_step_in_pixel,
src_whole_cols
)
;
int
i
;
GENTYPE_SRC
sum,
temp[READ_TIMES_COL]
;
__local
GENTYPE_SRC
LDS_DAT[LSIZE1
*
READ_TIMES_COL][LSIZE0
+
1]
;
srcT
sum,
temp[READ_TIMES_COL]
;
__local
srcT
LDS_DAT[LSIZE1
*
READ_TIMES_COL][LSIZE0
+
1]
;
//read
pixels
from
src
for
(
i
=
0
;i<READ_TIMES_COL;i++
)
//
read
pixels
from
src
for
(
int
i
=
0
; i < READ_TIMES_COL; ++i
)
{
int
current_addr
=
start_addr+i*LSIZE1*src_step_in_pixel
;
int
current_addr
=
mad24
(
i,
LSIZE1
*
src_step_in_pixel,
start_addr
)
;
current_addr
=
current_addr
<
end_addr
?
current_addr
:
0
;
temp[i]
=
src[current_addr]
;
}
//save
pixels
to
lds
for
(
i
=
0
;i<READ_TIMES_COL;i++)
{
LDS_DAT[l_y+i*LSIZE1][l_x]
=
temp[i]
;
}
//
save
pixels
to
lds
for
(
int
i
=
0
; i < READ_TIMES_COL; ++i)
LDS_DAT[mad24
(
i,
LSIZE1,
l_y
)
][l_x]
=
temp[i]
;
barrier
(
CLK_LOCAL_MEM_FENCE
)
;
//read
pixels
from
lds
and
calculate
the
result
sum
=
LDS_DAT[l_y+RADIUSY][l_x]*mat_kernel[RADIUSY]
;
for
(
i=1
;i<=RADIUSY;i++)
//
read
pixels
from
lds
and
calculate
the
result
sum
=
LDS_DAT[l_y
+
RADIUSY][l_x]
*
mat_kernel[RADIUSY]
;
for
(
int
i
=
1
; i <= RADIUSY; ++i)
{
temp[0]
=LDS_DAT[l_y+RADIUSY-
i][l_x]
;
temp[1]
=LDS_DAT[l_y+RADIUSY+
i][l_x]
;
sum
+=
temp[0]
*
mat_kernel[RADIUSY-i]+temp[1]
*
mat_kernel[RADIUSY+i]
;
temp[0]
=
LDS_DAT[l_y
+
RADIUSY
-
i][l_x]
;
temp[1]
=
LDS_DAT[l_y
+
RADIUSY
+
i][l_x]
;
sum
+=
mad
(
temp[0],
mat_kernel[RADIUSY
-
i],
temp[1]
*
mat_kernel[RADIUSY
+
i]
)
;
}
//write
the
result
to
dst
if
((
x<dst_cols
)
&
(
y<dst_rows
))
//
write
the
result
to
dst
if
(
x
<
dst_cols
&&
y
<
dst_rows
)
{
start_addr
=
mad24
(
y,
dst_step_in_pixel,
x
+
dst_offset_in_pixel
)
;
dst[start_addr]
=
convert
_to_DS
T
(
sum
)
;
dst[start_addr]
=
convert
ToDst
T
(
sum
)
;
}
}
modules/imgproc/src/opencl/filterSepRow.cl
View file @
b449b0bf
This diff is collapsed.
Click to expand it.
modules/imgproc/src/opencl/filterSep_singlePass.cl
View file @
b449b0bf
...
...
@@ -75,6 +75,7 @@
#endif
#define SRC(_x,_y) convertToWT(((global srcT*)(Src+(_y)*src_step))[_x])
#define DST(_x,_y) (((global dstT*)(Dst+dst_offset+(_y)*dst_step))[_x])
#ifdef BORDER_CONSTANT
// CCCCCC|abcdefgh|CCCCCCC
...
...
@@ -83,8 +84,6 @@
#
define
ELEM
(
_x,_y,r_edge,t_edge,const_v
)
SRC
((
_x
)
,
(
_y
))
#
endif
#
define
DST
(
_x,_y
)
(((
global
dstT*
)(
Dst+dst_offset+
(
_y
)
*dst_step
))
[_x]
)
#
define
noconvert
//
horizontal
and
vertical
filter
kernels
...
...
@@ -101,15 +100,15 @@ __kernel void sep_filter(__global uchar* Src, int src_step, int srcOffsetX, int
//
all
these
should
be
defined
on
host
during
compile
time
//
first
lsmem
array
for
source
pixels
used
in
first
pass,
//
second
lsmemDy
for
storing
first
pass
results
__local
WT
lsmem[BLK_Y
+2*RADIUSY][BLK_X+2*
RADIUSX]
;
__local
WT
lsmemDy[BLK_Y][BLK_X
+2*
RADIUSX]
;
__local
WT
lsmem[BLK_Y
+
2
*
RADIUSY][BLK_X
+
2
*
RADIUSX]
;
__local
WT
lsmemDy[BLK_Y][BLK_X
+
2
*
RADIUSX]
;
//
get
local
and
global
ids
-
used
as
image
and
local
memory
array
indexes
int
lix
=
get_local_id
(
0
)
;
int
liy
=
get_local_id
(
1
)
;
int
x
=
(
int
)
get_global_id
(
0
)
;
int
y
=
(
int
)
get_global_id
(
1
)
;
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
//
calculate
pixel
position
in
source
image
taking
image
offset
into
account
int
srcX
=
x
+
srcOffsetX
-
RADIUSX
;
...
...
modules/imgproc/test/ocl/test_sepfilter2D.cpp
View file @
b449b0bf
...
...
@@ -79,12 +79,14 @@ PARAM_TEST_CASE(SepFilter2D, MatDepth, Channels, BorderType, bool, bool)
ksize
.
width
++
;
if
(
1
!=
(
ksize
.
height
%
2
))
ksize
.
height
++
;
Mat
temp
=
randomMat
(
Size
(
ksize
.
width
,
1
),
CV_MAKE_TYPE
(
CV_32F
,
1
),
-
MAX_VALUE
,
MAX_VALUE
);
cv
::
normalize
(
temp
,
kernelX
,
1.0
,
0.0
,
NORM_L1
);
temp
=
randomMat
(
Size
(
1
,
ksize
.
height
),
CV_MAKE_TYPE
(
CV_32F
,
1
),
-
MAX_VALUE
,
MAX_VALUE
);
cv
::
normalize
(
temp
,
kernelY
,
1.0
,
0.0
,
NORM_L1
);
Size
roiSize
=
randomSize
(
ksize
.
width
,
MAX_VALUE
,
ksize
.
height
,
MAX_VALUE
);
Size
roiSize
=
randomSize
(
ksize
.
width
+
16
,
MAX_VALUE
,
ksize
.
height
+
20
,
MAX_VALUE
);
std
::
cout
<<
roiSize
<<
std
::
endl
;
int
rest
=
roiSize
.
width
%
4
;
if
(
0
!=
rest
)
roiSize
.
width
+=
(
4
-
rest
);
...
...
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