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
ee7eb1b8
Commit
ee7eb1b8
authored
Apr 29, 2013
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored Laplacian filter
parent
1eedc6c4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
61 deletions
+55
-61
gpufilters.hpp
modules/gpufilters/include/opencv2/gpufilters.hpp
+12
-6
perf_filters.cpp
modules/gpufilters/perf/perf_filters.cpp
+27
-25
filtering.cpp
modules/gpufilters/src/filtering.cpp
+13
-17
test_filters.cpp
modules/gpufilters/test/test_filters.cpp
+3
-13
No files found.
modules/gpufilters/include/opencv2/gpufilters.hpp
View file @
ee7eb1b8
...
...
@@ -113,17 +113,23 @@ inline void filter2D(InputArray src, OutputArray dst, int ddepth, InputArray ker
f
->
apply
(
src
,
dst
,
stream
);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Laplacian Filter
//! applies Laplacian operator to the image
//! supports only ksize = 1 and ksize = 3
CV_EXPORTS
void
Laplacian
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
int
ddepth
,
int
ksize
=
1
,
double
scale
=
1
,
int
borderType
=
BORDER_DEFAULT
,
Stream
&
stream
=
Stream
::
Null
());
CV_EXPORTS
Ptr
<
Filter
>
createLaplacianFilter
(
int
srcType
,
int
dstType
,
int
ksize
=
1
,
double
scale
=
1
,
int
borderMode
=
BORDER_DEFAULT
,
Scalar
borderVal
=
Scalar
::
all
(
0
));
__OPENCV_GPUFILTERS_DEPR_BEFORE__
void
Laplacian
(
InputArray
src
,
OutputArray
dst
,
int
ddepth
,
int
ksize
=
1
,
double
scale
=
1
,
int
borderType
=
BORDER_DEFAULT
,
Stream
&
stream
=
Stream
::
Null
())
__OPENCV_GPUFILTERS_DEPR_AFTER__
;
inline
void
Laplacian
(
InputArray
src
,
OutputArray
dst
,
int
ddepth
,
int
ksize
,
double
scale
,
int
borderType
,
Stream
&
stream
)
{
Ptr
<
gpu
::
Filter
>
f
=
gpu
::
createLaplacianFilter
(
src
.
type
(),
ddepth
,
ksize
,
scale
,
borderType
);
f
->
apply
(
src
,
dst
,
stream
);
}
...
...
modules/gpufilters/perf/perf_filters.cpp
View file @
ee7eb1b8
...
...
@@ -124,17 +124,10 @@ PERF_TEST_P(Sz_Type_KernelSz, Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV
}
}
//////////////////////////////////////////////////////////////////////
//
Sobel
//
Laplacian
PERF_TEST_P
(
Sz_Type_KernelSz
,
Sobel
,
Combine
(
GPU_TYPICAL_MAT_SIZES
,
Values
(
CV_8UC1
,
CV_8UC4
,
CV_32FC1
),
Values
(
3
,
5
,
7
,
9
,
11
,
13
,
15
)))
PERF_TEST_P
(
Sz_Type_KernelSz
,
Laplacian
,
Combine
(
GPU_TYPICAL_MAT_SIZES
,
Values
(
CV_8UC1
,
CV_8UC4
,
CV_32FC1
,
CV_32FC4
),
Values
(
1
,
3
)))
{
declare
.
time
(
20.0
);
...
...
@@ -149,9 +142,10 @@ PERF_TEST_P(Sz_Type_KernelSz, Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
{
const
cv
::
gpu
::
GpuMat
d_src
(
src
);
cv
::
gpu
::
GpuMat
dst
;
cv
::
gpu
::
GpuMat
d_buf
;
TEST_CYCLE
()
cv
::
gpu
::
Sobel
(
d_src
,
dst
,
-
1
,
1
,
1
,
d_buf
,
ksize
);
cv
::
Ptr
<
cv
::
gpu
::
Filter
>
laplacian
=
cv
::
gpu
::
createLaplacianFilter
(
d_src
.
type
(),
-
1
,
ksize
);
TEST_CYCLE
()
laplacian
->
apply
(
d_src
,
dst
);
GPU_SANITY_CHECK
(
dst
);
}
...
...
@@ -159,21 +153,29 @@ PERF_TEST_P(Sz_Type_KernelSz, Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
{
cv
::
Mat
dst
;
TEST_CYCLE
()
cv
::
Sobel
(
src
,
dst
,
-
1
,
1
,
1
,
ksize
);
TEST_CYCLE
()
cv
::
Laplacian
(
src
,
dst
,
-
1
,
ksize
);
CPU_SANITY_CHECK
(
dst
);
}
}
//////////////////////////////////////////////////////////////////////
// S
charr
// S
obel
PERF_TEST_P
(
Sz_Type
,
Scharr
,
Combine
(
GPU_TYPICAL_MAT_SIZES
,
Values
(
CV_8UC1
,
CV_8UC4
,
CV_32FC1
)))
PERF_TEST_P
(
Sz_Type
_KernelSz
,
Sobel
,
Combine
(
GPU_TYPICAL_MAT_SIZES
,
Values
(
CV_8UC1
,
CV_8UC4
,
CV_32FC1
),
Values
(
3
,
5
,
7
,
9
,
11
,
13
,
15
)))
{
declare
.
time
(
20.0
);
const
cv
::
Size
size
=
GET_PARAM
(
0
);
const
int
type
=
GET_PARAM
(
1
);
const
int
ksize
=
GET_PARAM
(
2
);
cv
::
Mat
src
(
size
,
type
);
declare
.
in
(
src
,
WARMUP_RNG
);
...
...
@@ -184,7 +186,7 @@ PERF_TEST_P(Sz_Type, Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8
cv
::
gpu
::
GpuMat
dst
;
cv
::
gpu
::
GpuMat
d_buf
;
TEST_CYCLE
()
cv
::
gpu
::
S
charr
(
d_src
,
dst
,
-
1
,
1
,
0
,
d_buf
);
TEST_CYCLE
()
cv
::
gpu
::
S
obel
(
d_src
,
dst
,
-
1
,
1
,
1
,
d_buf
,
ksize
);
GPU_SANITY_CHECK
(
dst
);
}
...
...
@@ -192,22 +194,21 @@ PERF_TEST_P(Sz_Type, Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8
{
cv
::
Mat
dst
;
TEST_CYCLE
()
cv
::
S
charr
(
src
,
dst
,
-
1
,
1
,
0
);
TEST_CYCLE
()
cv
::
S
obel
(
src
,
dst
,
-
1
,
1
,
1
,
ksize
);
CPU_SANITY_CHECK
(
dst
);
}
}
//////////////////////////////////////////////////////////////////////
//
GaussianBlu
r
//
Schar
r
PERF_TEST_P
(
Sz_Type
_KernelSz
,
GaussianBlur
,
Combine
(
GPU_TYPICAL_MAT_SIZES
,
Values
(
CV_8UC1
,
CV_8UC4
,
CV_32FC1
),
Values
(
3
,
5
,
7
,
9
,
11
,
13
,
15
)))
PERF_TEST_P
(
Sz_Type
,
Scharr
,
Combine
(
GPU_TYPICAL_MAT_SIZES
,
Values
(
CV_8UC1
,
CV_8UC4
,
CV_32FC1
)))
{
declare
.
time
(
20.0
);
const
cv
::
Size
size
=
GET_PARAM
(
0
);
const
int
type
=
GET_PARAM
(
1
);
const
int
ksize
=
GET_PARAM
(
2
);
cv
::
Mat
src
(
size
,
type
);
declare
.
in
(
src
,
WARMUP_RNG
);
...
...
@@ -218,7 +219,7 @@ PERF_TEST_P(Sz_Type_KernelSz, GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZES, Value
cv
::
gpu
::
GpuMat
dst
;
cv
::
gpu
::
GpuMat
d_buf
;
TEST_CYCLE
()
cv
::
gpu
::
GaussianBlur
(
d_src
,
dst
,
cv
::
Size
(
ksize
,
ksize
),
d_buf
,
0.5
);
TEST_CYCLE
()
cv
::
gpu
::
Scharr
(
d_src
,
dst
,
-
1
,
1
,
0
,
d_buf
);
GPU_SANITY_CHECK
(
dst
);
}
...
...
@@ -226,16 +227,16 @@ PERF_TEST_P(Sz_Type_KernelSz, GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZES, Value
{
cv
::
Mat
dst
;
TEST_CYCLE
()
cv
::
GaussianBlur
(
src
,
dst
,
cv
::
Size
(
ksize
,
ksize
),
0.5
);
TEST_CYCLE
()
cv
::
Scharr
(
src
,
dst
,
-
1
,
1
,
0
);
CPU_SANITY_CHECK
(
dst
);
}
}
//////////////////////////////////////////////////////////////////////
//
Laplacian
//
GaussianBlur
PERF_TEST_P
(
Sz_Type_KernelSz
,
Laplacian
,
Combine
(
GPU_TYPICAL_MAT_SIZES
,
Values
(
CV_8UC1
,
CV_8UC4
,
CV_32FC1
,
CV_32FC4
),
Values
(
1
,
3
)))
PERF_TEST_P
(
Sz_Type_KernelSz
,
GaussianBlur
,
Combine
(
GPU_TYPICAL_MAT_SIZES
,
Values
(
CV_8UC1
,
CV_8UC4
,
CV_32FC1
),
Values
(
3
,
5
,
7
,
9
,
11
,
13
,
15
)))
{
declare
.
time
(
20.0
);
...
...
@@ -250,8 +251,9 @@ PERF_TEST_P(Sz_Type_KernelSz, Laplacian, Combine(GPU_TYPICAL_MAT_SIZES, Values(C
{
const
cv
::
gpu
::
GpuMat
d_src
(
src
);
cv
::
gpu
::
GpuMat
dst
;
cv
::
gpu
::
GpuMat
d_buf
;
TEST_CYCLE
()
cv
::
gpu
::
Laplacian
(
d_src
,
dst
,
-
1
,
ksize
);
TEST_CYCLE
()
cv
::
gpu
::
GaussianBlur
(
d_src
,
dst
,
cv
::
Size
(
ksize
,
ksize
),
d_buf
,
0.5
);
GPU_SANITY_CHECK
(
dst
);
}
...
...
@@ -259,7 +261,7 @@ PERF_TEST_P(Sz_Type_KernelSz, Laplacian, Combine(GPU_TYPICAL_MAT_SIZES, Values(C
{
cv
::
Mat
dst
;
TEST_CYCLE
()
cv
::
Laplacian
(
src
,
dst
,
-
1
,
ksize
);
TEST_CYCLE
()
cv
::
GaussianBlur
(
src
,
dst
,
cv
::
Size
(
ksize
,
ksize
),
0.5
);
CPU_SANITY_CHECK
(
dst
);
}
...
...
modules/gpufilters/src/filtering.cpp
View file @
ee7eb1b8
...
...
@@ -51,6 +51,8 @@ Ptr<Filter> cv::gpu::createBoxFilter(int, int, Size, Point, int, Scalar) { throw
Ptr
<
Filter
>
cv
::
gpu
::
createLinearFilter
(
int
,
int
,
InputArray
,
Point
,
int
,
Scalar
)
{
throw_no_cuda
();
return
Ptr
<
Filter
>
();
}
Ptr
<
Filter
>
cv
::
gpu
::
createLaplacianFilter
(
int
,
int
,
int
,
double
,
int
,
Scalar
)
{
throw_no_cuda
();
return
Ptr
<
Filter
>
();
}
Ptr
<
FilterEngine_GPU
>
cv
::
gpu
::
createFilter2D_GPU
(
const
Ptr
<
BaseFilter_GPU
>&
,
int
,
int
)
{
throw_no_cuda
();
return
Ptr
<
FilterEngine_GPU
>
(
0
);
}
Ptr
<
FilterEngine_GPU
>
cv
::
gpu
::
createSeparableFilter_GPU
(
const
Ptr
<
BaseRowFilter_GPU
>&
,
const
Ptr
<
BaseColumnFilter_GPU
>&
,
int
,
int
,
int
)
{
throw_no_cuda
();
return
Ptr
<
FilterEngine_GPU
>
(
0
);
}
Ptr
<
FilterEngine_GPU
>
cv
::
gpu
::
createSeparableFilter_GPU
(
const
Ptr
<
BaseRowFilter_GPU
>&
,
const
Ptr
<
BaseColumnFilter_GPU
>&
,
int
,
int
,
int
,
GpuMat
&
)
{
throw_no_cuda
();
return
Ptr
<
FilterEngine_GPU
>
(
0
);
}
...
...
@@ -84,7 +86,6 @@ void cv::gpu::Scharr(const GpuMat&, GpuMat&, int, int, int, double, int, int) {
void
cv
::
gpu
::
Scharr
(
const
GpuMat
&
,
GpuMat
&
,
int
,
int
,
int
,
GpuMat
&
,
double
,
int
,
int
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
GaussianBlur
(
const
GpuMat
&
,
GpuMat
&
,
Size
,
double
,
double
,
int
,
int
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
GaussianBlur
(
const
GpuMat
&
,
GpuMat
&
,
Size
,
GpuMat
&
,
double
,
double
,
int
,
int
,
Stream
&
)
{
throw_no_cuda
();
}
void
cv
::
gpu
::
Laplacian
(
const
GpuMat
&
,
GpuMat
&
,
int
,
int
,
double
,
int
,
Stream
&
)
{
throw_no_cuda
();
}
#else
...
...
@@ -293,30 +294,24 @@ Ptr<Filter> cv::gpu::createLinearFilter(int srcType, int dstType, InputArray ker
return
new
LinearFilter
(
srcType
,
dstType
,
kernel
,
anchor
,
borderMode
,
borderVal
);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Laplacian Filter
void
cv
::
gpu
::
Laplacian
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
int
ddepth
,
int
ksize
,
double
scale
,
int
borderType
,
Stream
&
stream
)
Ptr
<
Filter
>
cv
::
gpu
::
createLaplacianFilter
(
int
srcType
,
int
dstType
,
int
ksize
,
double
scale
,
int
borderMode
,
Scalar
borderVal
)
{
CV_Assert
(
ksize
==
1
||
ksize
==
3
);
CV_Assert
(
ksize
==
1
||
ksize
==
3
);
static
const
in
t
K
[
2
][
9
]
=
static
const
floa
t
K
[
2
][
9
]
=
{
{
0
,
1
,
0
,
1
,
-
4
,
1
,
0
,
1
,
0
},
{
2
,
0
,
2
,
0
,
-
8
,
0
,
2
,
0
,
2
}
{
0
.0
f
,
1.0
f
,
0.0
f
,
1.0
f
,
-
4.0
f
,
1.0
f
,
0.0
f
,
1.0
f
,
0.0
f
},
{
2
.0
f
,
0.0
f
,
2.0
f
,
0.0
f
,
-
8.0
f
,
0.0
f
,
2.0
f
,
0.0
f
,
2.0
f
}
};
Mat
kernel
(
3
,
3
,
CV_32S
,
(
void
*
)
K
[
ksize
==
3
]);
Mat
kernel
(
3
,
3
,
CV_32FC1
,
(
void
*
)
K
[
ksize
==
3
]);
if
(
scale
!=
1
)
kernel
*=
scale
;
Ptr
<
gpu
::
Filter
>
f
=
gpu
::
createLinearFilter
(
src
.
type
(),
ddepth
,
kernel
,
Point
(
-
1
,
-
1
),
borderType
);
f
->
apply
(
src
,
dst
,
stream
);
return
gpu
::
createLinearFilter
(
srcType
,
dstType
,
kernel
,
Point
(
-
1
,
-
1
),
borderMode
,
borderVal
);
}
...
...
@@ -337,6 +332,7 @@ void cv::gpu::Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize, d
...
...
modules/gpufilters/test/test_filters.cpp
View file @
ee7eb1b8
...
...
@@ -170,18 +170,6 @@ INSTANTIATE_TEST_CASE_P(GPU_Filters, Filter2D, testing::Combine(
testing
::
Values
(
BorderType
(
cv
::
BORDER_REFLECT101
),
BorderType
(
cv
::
BORDER_REPLICATE
),
BorderType
(
cv
::
BORDER_CONSTANT
),
BorderType
(
cv
::
BORDER_REFLECT
)),
WHOLE_SUBMAT
));
/////////////////////////////////////////////////////////////////////////////////////////////////
// Laplacian
...
...
@@ -209,8 +197,10 @@ GPU_TEST_P(Laplacian, Accuracy)
{
cv
::
Mat
src
=
randomMat
(
size
,
type
);
cv
::
Ptr
<
cv
::
gpu
::
Filter
>
laplacian
=
cv
::
gpu
::
createLaplacianFilter
(
src
.
type
(),
-
1
,
ksize
.
width
);
cv
::
gpu
::
GpuMat
dst
=
createMat
(
size
,
type
,
useRoi
);
cv
::
gpu
::
Laplacian
(
loadMat
(
src
,
useRoi
),
dst
,
-
1
,
ksize
.
width
);
laplacian
->
apply
(
loadMat
(
src
,
useRoi
),
dst
);
cv
::
Mat
dst_gold
;
cv
::
Laplacian
(
src
,
dst_gold
,
-
1
,
ksize
.
width
);
...
...
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