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
a51ab99a
Commit
a51ab99a
authored
Mar 18, 2014
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added 3-channels support to cv::filter2D, cv::Laplacian
parent
e19c42dd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
19 deletions
+31
-19
filter.cpp
modules/imgproc/src/filter.cpp
+4
-5
filter2D.cl
modules/imgproc/src/opencl/filter2D.cl
+24
-6
smooth.cpp
modules/imgproc/src/smooth.cpp
+0
-4
test_filter2d.cpp
modules/imgproc/test/ocl/test_filter2d.cpp
+2
-3
test_filters.cpp
modules/imgproc/test/ocl/test_filters.cpp
+1
-1
No files found.
modules/imgproc/src/filter.cpp
View file @
a51ab99a
...
...
@@ -3157,10 +3157,9 @@ static bool ocl_filter2D( InputArray _src, OutputArray _dst, int ddepth,
if
(
abs
(
delta
)
>
FLT_MIN
)
return
false
;
int
type
=
_src
.
type
();
int
cn
=
CV_MAT_CN
(
type
);
if
((
1
!=
cn
)
&&
(
2
!=
cn
)
&&
(
4
!=
cn
))
return
false
;
//TODO
int
type
=
_src
.
type
(),
cn
=
CV_MAT_CN
(
type
);
if
(
cn
>
4
)
return
false
;
int
sdepth
=
CV_MAT_DEPTH
(
type
);
Size
ksize
=
_kernel
.
size
();
...
...
@@ -3298,7 +3297,7 @@ static bool ocl_filter2D( InputArray _src, OutputArray _dst, int ddepth,
double
borderValueDouble
[
4
]
=
{
0
,
0
,
0
,
0
};
if
((
borderType
&
~
BORDER_ISOLATED
)
==
BORDER_CONSTANT
)
{
int
cnocl
=
(
3
==
cn
)
?
4
:
cn
;
int
cnocl
=
3
==
cn
?
4
:
cn
;
if
(
useDouble
)
idxArg
=
kernel
.
set
(
idxArg
,
(
void
*
)
&
borderValueDouble
[
0
],
sizeof
(
double
)
*
cnocl
);
else
...
...
modules/imgproc/src/opencl/filter2D.cl
View file @
a51ab99a
...
...
@@ -203,10 +203,24 @@
#
define
VEC_TYPE
CAT
(
BASE_TYPE,
VEC_SIZE
)
#
define
TYPE
VEC_TYPE
#
if
VEC_SIZE
==
3
#
define
SCALAR_TYPE
CAT
(
FPTYPE,
4
)
#
else
#
define
SCALAR_TYPE
CAT
(
FPTYPE,
VEC_SIZE
)
#
endif
#
define
INTERMEDIATE_TYPE
CAT
(
FPTYPE,
VEC_SIZE
)
#
if
DATA_CHAN
!=
3
#
define
loadpix
(
addr
)
*
(
__global
const
TYPE
*
)(
addr
)
#
define
storepix
(
val,
addr
)
*
(
__global
TYPE
*
)(
addr
)
=
val
#
define
TSIZE
(
int
)
sizeof
(
TYPE
)
#
else
#
define
loadpix
(
addr
)
vload3
(
0
,
(
__global
const
BASE_TYPE
*
)(
addr
))
#
define
storepix
(
val,
addr
)
vstore3
(
val,
0
,
(
__global
BASE_TYPE
*
)(
addr
))
#
define
TSIZE
(
int
)
sizeof
(
BASE_TYPE
)
*DATA_CHAN
#
endif
struct
RectCoords
{
int
x1,
y1,
x2,
y2
;
...
...
@@ -235,13 +249,17 @@ inline INTERMEDIATE_TYPE readSrcPixel(int2 pos, __global const uchar* srcptr, in
#
endif
{
//__global
TYPE*
ptr
=
(
__global
TYPE*
)((
__global
char*
)
src
+
pos.x
*
sizeof
(
TYPE
)
+
pos.y
*
srcStepBytes
)
;
__global
TYPE*
ptr
=
(
__global
TYPE*
)(
srcptr
+
pos.y
*
srcstep
+
pos.x
*
sizeof
(
TYPE
)
)
;
return
CONVERT_TO_FPTYPE
(
*ptr
)
;
__global
TYPE*
ptr
=
(
__global
TYPE*
)(
srcptr
+
pos.y
*
srcstep
+
pos.x
*
TSIZE
)
;
return
CONVERT_TO_FPTYPE
(
loadpix
(
ptr
)
)
;
}
else
{
#
ifdef
BORDER_CONSTANT
#
if
VEC_SIZE
==
3
return
(
INTERMEDIATE_TYPE
)(
borderValue.x,
borderValue.y,
borderValue.z
)
;
#
else
return
borderValue
;
#
endif
#
else
int
selected_col
=
pos.x
;
int
selected_row
=
pos.y
;
...
...
@@ -262,8 +280,8 @@ inline INTERMEDIATE_TYPE readSrcPixel(int2 pos, __global const uchar* srcptr, in
if
(
pos.x
>=
0
&&
pos.y
>=
0
&&
pos.x
<
srcCoords.x2
&&
pos.y
<
srcCoords.y2
)
{
//__global
TYPE*
ptr
=
(
__global
TYPE*
)((
__global
char*
)
src
+
pos.x
*
sizeof
(
TYPE
)
+
pos.y
*
srcStepBytes
)
;
__global
TYPE*
ptr
=
(
__global
TYPE*
)(
srcptr
+
pos.y
*
srcstep
+
pos.x
*
sizeof
(
TYPE
)
)
;
return
CONVERT_TO_FPTYPE
(
*ptr
)
;
__global
TYPE*
ptr
=
(
__global
TYPE*
)(
srcptr
+
pos.y
*
srcstep
+
pos.x
*
TSIZE
)
;
return
CONVERT_TO_FPTYPE
(
loadpix
(
ptr
)
)
;
}
else
{
...
...
@@ -300,7 +318,7 @@ void filter2D(__global const uchar* srcptr, int srcstep, int srcOffsetX, int src
int2
srcPos
=
(
int2
)(
srcCoords.x1
+
x,
srcCoords.y1
+
y
-
ANCHOR_Y
)
;
int2
pos
=
(
int2
)(
x,
y
)
;
__global
TYPE*
dstPtr
=
(
__global
TYPE*
)((
__global
char*
)
dstptr
+
pos.y
*
dststep
+
dstoffset
+
pos.x
*
sizeof
(
TYPE
)
)
; // Pointer can be out of bounds!
__global
TYPE*
dstPtr
=
(
__global
TYPE*
)((
__global
char*
)
dstptr
+
pos.y
*
dststep
+
dstoffset
+
pos.x
*
TSIZE
)
; // Pointer can be out of bounds!
bool
writeResult
=
((
local_id
>=
ANCHOR_X
)
&&
(
local_id
<
LOCAL_SIZE
-
(
KERNEL_SIZE_X
-
1
-
ANCHOR_X
))
&&
(
pos.x
>=
0
)
&&
(
pos.x
<
cols
))
;
...
...
@@ -360,7 +378,7 @@ void filter2D(__global const uchar* srcptr, int srcstep, int srcOffsetX, int src
if
(
writeResult
)
{
*dstPtr
=
CONVERT_TO_TYPE
(
total_sum
)
;
storepix
(
CONVERT_TO_TYPE
(
total_sum
)
,
dstPtr
)
;
}
#
if
BLOCK_SIZE_Y
>
1
...
...
modules/imgproc/src/smooth.cpp
View file @
a51ab99a
...
...
@@ -41,7 +41,6 @@
//M*/
#include "precomp.hpp"
#define CV_OPENCL_RUN_ASSERT
#include "opencl_kernels.hpp"
/*
...
...
@@ -642,10 +641,7 @@ static bool ocl_boxFilter( InputArray _src, OutputArray _dst, int ddepth,
if
(
cn
>
4
||
(
!
doubleSupport
&&
(
sdepth
==
CV_64F
||
ddepth
==
CV_64F
))
||
_src
.
offset
()
%
esz
!=
0
||
_src
.
step
()
%
esz
!=
0
)
{
printf
(
"!!!!!!!!!!!!!!!!!!!!!!!
\n
"
);
return
false
;
}
if
(
anchor
.
x
<
0
)
anchor
.
x
=
ksize
.
width
/
2
;
...
...
modules/imgproc/test/ocl/test_filter2d.cpp
View file @
a51ab99a
...
...
@@ -115,11 +115,10 @@ OCL_TEST_P(Filter2D, Mat)
}
}
OCL_INSTANTIATE_TEST_CASE_P
(
ImageProc
,
Filter2D
,
Combine
(
Values
(
CV_8U
,
CV_16U
,
CV_
16S
,
CV_32F
,
CV_64
F
),
Values
(
1
,
2
,
4
)
,
Values
(
CV_8U
,
CV_16U
,
CV_
32
F
),
OCL_ALL_CHANNELS
,
Values
((
BorderType
)
BORDER_CONSTANT
,
(
BorderType
)
BORDER_REPLICATE
,
(
BorderType
)
BORDER_REFLECT
,
...
...
modules/imgproc/test/ocl/test_filters.cpp
View file @
a51ab99a
...
...
@@ -304,7 +304,7 @@ OCL_TEST_P(MorphologyEx, Mat)
(int)BORDER_REFLECT|BORDER_ISOLATED, (int)BORDER_WRAP|BORDER_ISOLATED, \
(int)BORDER_REFLECT_101|BORDER_ISOLATED*/
) // WRAP and ISOLATED are not supported by cv:: version
#define FILTER_TYPES Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4)
#define FILTER_TYPES Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_
16UC1, CV_16UC3, CV_16UC4, CV_
32FC1, CV_32FC3, CV_32FC4)
OCL_INSTANTIATE_TEST_CASE_P
(
Filter
,
Bilateral
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
),
...
...
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