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
cd6e7ac4
Commit
cd6e7ac4
authored
Sep 19, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7252 from terfendail:transparent_sobel_fix
parents
86f01c25
48f132f3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
11 deletions
+60
-11
canny.cpp
modules/imgproc/src/canny.cpp
+3
-0
deriv.cpp
modules/imgproc/src/deriv.cpp
+5
-1
test_canny.cpp
modules/imgproc/test/ocl/test_canny.cpp
+2
-10
test_filter.cpp
modules/imgproc/test/test_filter.cpp
+50
-0
No files found.
modules/imgproc/src/canny.cpp
View file @
cd6e7ac4
...
...
@@ -69,6 +69,9 @@ static bool ippCanny(const Mat& _src, const Mat& dx_, const Mat& dy_, Mat& _dst,
CV_INSTRUMENT_REGION_IPP
()
#if USE_IPP_CANNY
if
(
!
useCustomDeriv
&&
_src
.
isSubmatrix
())
return
false
;
// IPP Sobel doesn't support transparent ROI border
int
size
=
0
,
size1
=
0
;
IppiSize
roi
=
{
_src
.
cols
,
_src
.
rows
};
...
...
modules/imgproc/src/deriv.cpp
View file @
cd6e7ac4
...
...
@@ -307,7 +307,7 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
{
CV_INSTRUMENT_REGION_IPP
()
if
((
borderType
!=
BORDER_REPLICATE
)
||
((
3
!=
ksize
)
&&
(
5
!=
ksize
)))
if
((
(
borderType
&
~
BORDER_ISOLATED
)
!=
BORDER_REPLICATE
)
||
((
3
!=
ksize
)
&&
(
5
!=
ksize
)))
return
false
;
if
(
fabs
(
delta
)
>
FLT_EPSILON
)
return
false
;
...
...
@@ -317,6 +317,10 @@ static bool IPPDerivSobel(InputArray _src, OutputArray _dst, int ddepth, int dx,
int
bufSize
=
0
;
cv
::
AutoBuffer
<
char
>
buffer
;
Mat
src
=
_src
.
getMat
(),
dst
=
_dst
.
getMat
();
if
((
borderType
&
BORDER_ISOLATED
)
==
0
&&
src
.
isSubmatrix
())
return
false
;
if
(
ddepth
<
0
)
ddepth
=
src
.
depth
();
...
...
modules/imgproc/test/ocl/test_canny.cpp
View file @
cd6e7ac4
...
...
@@ -99,11 +99,7 @@ OCL_TEST_P(Canny, Accuracy)
generateTestData
();
const
double
low_thresh
=
50.0
,
high_thresh
=
100.0
;
double
eps
=
1e-2
;
#ifdef ANDROID
if
(
cv
::
ocl
::
Device
::
getDefault
().
isNVidia
())
eps
=
12e-3
;
#endif
double
eps
=
12e-3
;
OCL_OFF
(
cv
::
Canny
(
src_roi
,
dst_roi
,
low_thresh
,
high_thresh
,
aperture_size
,
useL2gradient
));
OCL_ON
(
cv
::
Canny
(
usrc_roi
,
udst_roi
,
low_thresh
,
high_thresh
,
aperture_size
,
useL2gradient
));
...
...
@@ -117,11 +113,7 @@ OCL_TEST_P(Canny, AccuracyCustomGradient)
generateTestData
();
const
double
low_thresh
=
50.0
,
high_thresh
=
100.0
;
double
eps
=
1e-2
;
#ifdef ANDROID
if
(
cv
::
ocl
::
Device
::
getDefault
().
isNVidia
())
eps
=
12e-3
;
#endif
double
eps
=
12e-3
;
OCL_OFF
(
cv
::
Canny
(
src_roi
,
dst_roi
,
low_thresh
,
high_thresh
,
aperture_size
,
useL2gradient
));
OCL_ON
(
...
...
modules/imgproc/test/test_filter.cpp
View file @
cd6e7ac4
...
...
@@ -2015,3 +2015,53 @@ TEST(Imgproc_Morphology, iterated)
ASSERT_EQ
(
0.0
,
norm
(
dst0
,
dst2
,
NORM_INF
));
}
}
TEST
(
Imgproc_Sobel
,
borderTypes
)
{
int
kernelSize
=
3
;
/// ksize > src_roi.size()
Mat
src
=
(
Mat_
<
uchar
>
(
3
,
3
)
<<
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
),
dst
,
expected_dst
;
Mat
src_roi
=
src
(
Rect
(
1
,
1
,
1
,
1
));
src_roi
.
setTo
(
cv
::
Scalar
::
all
(
0
));
// should work like !BORDER_ISOLATED, so the function MUST read values in full matrix
Sobel
(
src_roi
,
dst
,
CV_16S
,
1
,
0
,
kernelSize
,
1
,
0
,
BORDER_REPLICATE
);
EXPECT_EQ
(
8
,
dst
.
at
<
short
>
(
0
,
0
));
Sobel
(
src_roi
,
dst
,
CV_16S
,
1
,
0
,
kernelSize
,
1
,
0
,
BORDER_REFLECT
);
EXPECT_EQ
(
8
,
dst
.
at
<
short
>
(
0
,
0
));
// should work like BORDER_ISOLATED
Sobel
(
src_roi
,
dst
,
CV_16S
,
1
,
0
,
kernelSize
,
1
,
0
,
BORDER_REPLICATE
|
BORDER_ISOLATED
);
EXPECT_EQ
(
0
,
dst
.
at
<
short
>
(
0
,
0
));
Sobel
(
src_roi
,
dst
,
CV_16S
,
1
,
0
,
kernelSize
,
1
,
0
,
BORDER_REFLECT
|
BORDER_ISOLATED
);
EXPECT_EQ
(
0
,
dst
.
at
<
short
>
(
0
,
0
));
/// ksize <= src_roi.size()
src
=
Mat
(
5
,
5
,
CV_8UC1
,
cv
::
Scalar
(
5
));
src_roi
=
src
(
Rect
(
1
,
1
,
3
,
3
));
src_roi
.
setTo
(
0
);
// should work like !BORDER_ISOLATED, so the function MUST read values in full matrix
expected_dst
=
(
Mat_
<
short
>
(
3
,
3
)
<<
-
15
,
0
,
15
,
-
20
,
0
,
20
,
-
15
,
0
,
15
);
Sobel
(
src_roi
,
dst
,
CV_16S
,
1
,
0
,
kernelSize
,
1
,
0
,
BORDER_REPLICATE
);
EXPECT_EQ
(
expected_dst
.
type
(),
dst
.
type
());
EXPECT_EQ
(
expected_dst
.
size
(),
dst
.
size
());
EXPECT_DOUBLE_EQ
(
0.0
,
cvtest
::
norm
(
expected_dst
,
dst
,
NORM_INF
));
Sobel
(
src_roi
,
dst
,
CV_16S
,
1
,
0
,
kernelSize
,
1
,
0
,
BORDER_REFLECT
);
EXPECT_EQ
(
expected_dst
.
type
(),
dst
.
type
());
EXPECT_EQ
(
expected_dst
.
size
(),
dst
.
size
());
EXPECT_DOUBLE_EQ
(
0.0
,
cvtest
::
norm
(
expected_dst
,
dst
,
NORM_INF
));
// should work like !BORDER_ISOLATED, so the function MUST read values in full matrix
expected_dst
=
Mat
::
zeros
(
3
,
3
,
CV_16SC1
);
Sobel
(
src_roi
,
dst
,
CV_16S
,
1
,
0
,
kernelSize
,
1
,
0
,
BORDER_REPLICATE
|
BORDER_ISOLATED
);
EXPECT_EQ
(
expected_dst
.
type
(),
dst
.
type
());
EXPECT_EQ
(
expected_dst
.
size
(),
dst
.
size
());
EXPECT_DOUBLE_EQ
(
0.0
,
cvtest
::
norm
(
expected_dst
,
dst
,
NORM_INF
));
Sobel
(
src_roi
,
dst
,
CV_16S
,
1
,
0
,
kernelSize
,
1
,
0
,
BORDER_REFLECT
|
BORDER_ISOLATED
);
EXPECT_EQ
(
expected_dst
.
type
(),
dst
.
type
());
EXPECT_EQ
(
expected_dst
.
size
(),
dst
.
size
());
EXPECT_DOUBLE_EQ
(
0.0
,
cvtest
::
norm
(
expected_dst
,
dst
,
NORM_INF
));
}
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