Skip to content

Commit 815b125

Browse files
committed
opencv_contrib にあれこれ移行
1 parent acd145f commit 815b125

File tree

5 files changed

+500
-0
lines changed

5 files changed

+500
-0
lines changed

modules/ximgproc/include/opencv2/ximgproc.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include "ximgproc/color_match.hpp"
6464
#include "ximgproc/radon_transform.hpp"
6565
#include "ximgproc/find_ellipses.hpp"
66+
#include "ximgproc/sparse_table_morphology.hpp"
6667

6768

6869
/**
@@ -116,6 +117,8 @@
116117
117118
The size of the original image is required for compatibility with the imgproc functions when the boundary handling requires that pixel outside the image boundary are
118119
"on".
120+
121+
@defgroup ximgproc_sparse_table_morphology Morphology operation with sparse table approach.
119122
@}
120123
*/
121124

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// This file is part of OpenCV project.
2+
// It is subject to the license terms in the LICENSE file found in the top-level directory
3+
// of this distribution and at http://opencv.org/license.html.
4+
5+
#ifndef __OPENCV_SPARSE_TABLE_MORPHOLOGY_HPP__
6+
#define __OPENCV_SPARSE_TABLE_MORPHOLOGY_HPP__
7+
8+
#include <opencv2/core.hpp>
9+
10+
namespace cv {
11+
namespace ximgproc {
12+
namespace st {
13+
14+
//! @addtogroup ximgproc_sparse_table_morphology
15+
//! @{
16+
17+
/**
18+
* @brief Another implementation of cv::erode with sparse table approach.
19+
*
20+
* @param src input image; the number of channels can be arbitrary, but the depth should be one of
21+
* CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
22+
* @param dst output image of the same size and type as src.
23+
* @param kernel structuring element used for erosion; if `element=Mat()`, a `3 x 3` rectangular
24+
* structuring element is used. Kernel can be created using #getStructuringElement.
25+
* @param anchor position of the anchor within the element; default value (-1, -1) means that the
26+
* anchor is at the element center.
27+
* @param iterations number of times erosion is applied.
28+
* @param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
29+
* @param borderValue border value in case of a constant border
30+
*
31+
* @see cv::erode
32+
*/
33+
CV_EXPORTS_W void erode( InputArray src, OutputArray dst, InputArray kernel,
34+
Point anchor = Point(-1,-1), int iterations = 1,
35+
int borderType = BORDER_CONSTANT,
36+
const Scalar& borderValue = morphologyDefaultBorderValue() );
37+
38+
/**
39+
* @brief Another implementation of cv::dilate with sparse table approach.
40+
*
41+
* @param src input image; the number of channels can be arbitrary, but the depth should be one of
42+
* CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
43+
* @param dst output image of the same size and type as src.
44+
* @param kernel structuring element used for dilation; if element=Mat(), a 3 x 3 rectangular
45+
* structuring element is used. Kernel can be created using #getStructuringElement
46+
* @param anchor position of the anchor within the element; default value (-1, -1) means that the
47+
* anchor is at the element center.
48+
* @param iterations number of times dilation is applied.
49+
* @param borderType pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not suported.
50+
* @param borderValue border value in case of a constant border
51+
*
52+
* @see cv::dilate
53+
*/
54+
CV_EXPORTS_W void dilate( InputArray src, OutputArray dst, InputArray kernel,
55+
Point anchor = Point(-1,-1), int iterations = 1,
56+
int borderType = BORDER_CONSTANT,
57+
const Scalar& borderValue = morphologyDefaultBorderValue() );
58+
59+
/**
60+
* @brief Another implementation of cv::morphologyEx with sparse table approach.
61+
62+
* @param src Source image. The number of channels can be arbitrary. The depth should be one of
63+
* CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
64+
* @param dst Destination image of the same size and type as source image.
65+
* @param op Type of a morphological operation, see #MorphTypes
66+
* @param kernel Structuring element. It can be created using #getStructuringElement.
67+
* @param anchor Anchor position with the kernel. Negative values mean that the anchor is at the
68+
* kernel center.
69+
* @param iterations Number of times erosion and dilation are applied.
70+
* @param borderType Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
71+
* @param borderValue Border value in case of a constant border. The default value has a special
72+
* meaning.
73+
* @note The number of iterations is the number of times erosion or dilatation operation will be applied.
74+
* For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply
75+
* successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate).
76+
*
77+
* @see cv::morphologyEx
78+
*/
79+
CV_EXPORTS_W void morphologyEx( InputArray src, OutputArray dst,
80+
int op, InputArray kernel,
81+
Point anchor = Point(-1,-1), int iterations = 1,
82+
int borderType = BORDER_CONSTANT,
83+
const Scalar& borderValue = morphologyDefaultBorderValue() );
84+
85+
//! @}
86+
87+
} // namespace st
88+
} // namespace ximgproc
89+
} // namespace cv
90+
91+
#endif
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// This file is part of OpenCV project.
2+
// It is subject to the license terms in the LICENSE file found in the top-level directory
3+
// of this distribution and at http://opencv.org/license.html.
4+
#include "perf_precomp.hpp"
5+
6+
namespace opencv_test {
7+
namespace st_morphology {
8+
9+
typedef tuple<int, Size, int> STParams;
10+
11+
typedef TestBaseWithParam<STParams> STMorphologyPerfTest;
12+
13+
TEST(Typical_Erode, small)
14+
{
15+
16+
}
17+
18+
PERF_TEST_P(STMorphologyPerfTest, perf, Combine(Values(1,7, 21), Values(sz720p, sz2160p),
19+
Values(MORPH_ERODE, MORPH_DILATE, MORPH_OPEN, MORPH_CLOSE, MORPH_GRADIENT,MORPH_TOPHAT, MORPH_BLACKHAT)))
20+
{
21+
STParams params = GetParam();
22+
int seSize = get<0>(params);
23+
Size sz = get<1>(params);
24+
int op = get<2>(params);
25+
26+
Mat src(sz, CV_8U);
27+
Mat thresholded, dstRLE;
28+
Mat se = rl::getStructuringElement(MORPH_ELLIPSE, cv::Size(2 * seSize + 1, 2 * seSize + 1));
29+
30+
declare.in(src, WARMUP_RNG);
31+
32+
TEST_CYCLE_N(4)
33+
{
34+
rl::threshold(src, thresholded, 100.0, THRESH_BINARY);
35+
rl::morphologyEx(thresholded, dstRLE, op, se);
36+
}
37+
38+
SANITY_CHECK_NOTHING();
39+
}
40+
41+
typedef tuple<int, Size> STErodeParams;
42+
typedef TestBaseWithParam<STErodeParams> STErodePerfTest;
43+
PERF_TEST_P(STErodePerfTest, perf, Combine(Values(1, 7, 21), Values(sz720p, sz2160p)))
44+
{
45+
STErodeParams params = GetParam();
46+
int seSize = get<0>(params);
47+
Size sz = get<1>(params);
48+
49+
Mat src(sz, CV_8U);
50+
Mat thresholded, dstRLE;
51+
Mat se = rl::getStructuringElement(MORPH_ELLIPSE, cv::Size(2 * seSize + 1, 2 * seSize + 1));
52+
53+
declare.in(src, WARMUP_RNG);
54+
55+
TEST_CYCLE_N(4)
56+
{
57+
rl::threshold(src, thresholded, 100.0, THRESH_BINARY);
58+
rl::erode(thresholded, dstRLE, se);
59+
}
60+
61+
SANITY_CHECK_NOTHING();
62+
}
63+
64+
} // st
65+
} // morphology

0 commit comments

Comments
 (0)