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
426b3f61
Commit
426b3f61
authored
Jul 01, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4139 from swook:spatial_gradient
parents
d5afd070
20bf88ba
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
0 deletions
+121
-0
imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+22
-0
perf_spatialgradient.cpp
modules/imgproc/perf/perf_spatialgradient.cpp
+35
-0
precomp.hpp
modules/imgproc/src/precomp.hpp
+1
-0
spatialgradient.cpp
modules/imgproc/src/spatialgradient.cpp
+0
-0
test_filter.cpp
modules/imgproc/test/test_filter.cpp
+63
-0
No files found.
modules/imgproc/include/opencv2/imgproc.hpp
View file @
426b3f61
...
...
@@ -1369,6 +1369,28 @@ CV_EXPORTS_W void Sobel( InputArray src, OutputArray dst, int ddepth,
double
scale
=
1
,
double
delta
=
0
,
int
borderType
=
BORDER_DEFAULT
);
/** @brief Calculates the first order image derivative in both x and y using a Sobel operator
Equivalent to calling:
@code
Sobel( src, dx, CV_16SC1, 1, 0, 3 );
Sobel( src, dy, CV_16SC1, 0, 1, 3 );
@endcode
@param src input image.
@param dx output image with first-order derivative in x.
@param dy output image with first-order derivative in y.
@param ksize size of Sobel kernel. It must be 3.
@param borderType pixel extrapolation method, see cv::BorderTypes
@sa Sobel
*/
CV_EXPORTS_W
void
spatialGradient
(
InputArray
src
,
OutputArray
dx
,
OutputArray
dy
,
int
ksize
=
3
,
int
borderType
=
BORDER_DEFAULT
);
/** @brief Calculates the first x- or y- image derivative using Scharr operator.
The function computes the first x- or y- spatial image derivative using the Scharr operator. The
...
...
modules/imgproc/perf/perf_spatialgradient.cpp
0 → 100644
View file @
426b3f61
#include "perf_precomp.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
perf
;
using
namespace
testing
;
using
std
::
tr1
::
make_tuple
;
using
std
::
tr1
::
get
;
typedef
std
::
tr1
::
tuple
<
Size
,
int
,
int
>
Size_Ksize_BorderType_t
;
typedef
perf
::
TestBaseWithParam
<
Size_Ksize_BorderType_t
>
Size_Ksize_BorderType
;
PERF_TEST_P
(
Size_Ksize_BorderType
,
spatialGradient
,
Combine
(
SZ_ALL_HD
,
Values
(
3
),
Values
(
BORDER_DEFAULT
,
BORDER_REPLICATE
)
)
)
{
Size
size
=
std
::
tr1
::
get
<
0
>
(
GetParam
());
int
ksize
=
std
::
tr1
::
get
<
1
>
(
GetParam
());
int
borderType
=
std
::
tr1
::
get
<
2
>
(
GetParam
());
Mat
src
(
size
,
CV_8UC1
);
Mat
dx
(
size
,
CV_16SC1
);
Mat
dy
(
size
,
CV_16SC1
);
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
dx
,
dy
);
TEST_CYCLE
()
spatialGradient
(
src
,
dx
,
dy
,
ksize
,
borderType
);
SANITY_CHECK
(
dx
);
SANITY_CHECK
(
dy
);
}
modules/imgproc/src/precomp.hpp
View file @
426b3f61
...
...
@@ -49,6 +49,7 @@
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/core/private.hpp"
#include "opencv2/core/ocl.hpp"
#include "opencv2/hal.hpp"
#include <math.h>
#include <assert.h>
...
...
modules/imgproc/src/spatialgradient.cpp
0 → 100644
View file @
426b3f61
This diff is collapsed.
Click to expand it.
modules/imgproc/test/test_filter.cpp
View file @
426b3f61
...
...
@@ -552,6 +552,68 @@ void CV_SobelTest::prepare_to_validation( int /*test_case_idx*/ )
}
/////////////// spatialGradient ///////////////
class
CV_SpatialGradientTest
:
public
CV_DerivBaseTest
{
public
:
CV_SpatialGradientTest
();
protected
:
void
prepare_to_validation
(
int
test_case_idx
);
void
run_func
();
void
get_test_array_types_and_sizes
(
int
test_case_idx
,
vector
<
vector
<
Size
>
>&
sizes
,
vector
<
vector
<
int
>
>&
types
);
int
ksize
;
};
CV_SpatialGradientTest
::
CV_SpatialGradientTest
()
{
test_array
[
OUTPUT
].
push_back
(
NULL
);
test_array
[
REF_OUTPUT
].
push_back
(
NULL
);
inplace
=
false
;
}
void
CV_SpatialGradientTest
::
get_test_array_types_and_sizes
(
int
test_case_idx
,
vector
<
vector
<
Size
>
>&
sizes
,
vector
<
vector
<
int
>
>&
types
)
{
CV_DerivBaseTest
::
get_test_array_types_and_sizes
(
test_case_idx
,
sizes
,
types
);
sizes
[
OUTPUT
][
1
]
=
sizes
[
REF_OUTPUT
][
1
]
=
sizes
[
OUTPUT
][
0
];
// Inputs are only CV_8UC1 for now
types
[
INPUT
][
0
]
=
CV_8UC1
;
// Outputs are only CV_16SC1 for now
types
[
OUTPUT
][
0
]
=
types
[
OUTPUT
][
1
]
=
types
[
REF_OUTPUT
][
0
]
=
types
[
REF_OUTPUT
][
1
]
=
CV_16SC1
;
ksize
=
3
;
border
=
BORDER_DEFAULT
;
// TODO: Add BORDER_REPLICATE
}
void
CV_SpatialGradientTest
::
run_func
()
{
spatialGradient
(
test_mat
[
INPUT
][
0
],
test_mat
[
OUTPUT
][
0
],
test_mat
[
OUTPUT
][
1
],
ksize
,
border
);
}
void
CV_SpatialGradientTest
::
prepare_to_validation
(
int
/*test_case_idx*/
)
{
int
dx
,
dy
;
dx
=
1
;
dy
=
0
;
Sobel
(
test_mat
[
INPUT
][
0
],
test_mat
[
REF_OUTPUT
][
0
],
CV_16SC1
,
dx
,
dy
,
ksize
,
1
,
0
,
border
);
dx
=
0
;
dy
=
1
;
Sobel
(
test_mat
[
INPUT
][
0
],
test_mat
[
REF_OUTPUT
][
1
],
CV_16SC1
,
dx
,
dy
,
ksize
,
1
,
0
,
border
);
}
/////////////// laplace ///////////////
class
CV_LaplaceTest
:
public
CV_DerivBaseTest
...
...
@@ -1773,6 +1835,7 @@ TEST(Imgproc_Dilate, accuracy) { CV_DilateTest test; test.safe_run(); }
TEST
(
Imgproc_MorphologyEx
,
accuracy
)
{
CV_MorphExTest
test
;
test
.
safe_run
();
}
TEST
(
Imgproc_Filter2D
,
accuracy
)
{
CV_FilterTest
test
;
test
.
safe_run
();
}
TEST
(
Imgproc_Sobel
,
accuracy
)
{
CV_SobelTest
test
;
test
.
safe_run
();
}
TEST
(
Imgproc_SpatialGradient
,
accuracy
)
{
CV_SpatialGradientTest
test
;
test
.
safe_run
();
}
TEST
(
Imgproc_Laplace
,
accuracy
)
{
CV_LaplaceTest
test
;
test
.
safe_run
();
}
TEST
(
Imgproc_Blur
,
accuracy
)
{
CV_BlurTest
test
;
test
.
safe_run
();
}
TEST
(
Imgproc_GaussianBlur
,
accuracy
)
{
CV_GaussianBlurTest
test
;
test
.
safe_run
();
}
...
...
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