Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
4bb297af
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4bb297af
编写于
4月 29, 2013
作者:
V
Vladislav Vinogradov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactored Image Rank Filters
上级
5720eaf3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
106 addition
and
68 deletion
+106
-68
modules/gpufilters/include/opencv2/gpufilters.hpp
modules/gpufilters/include/opencv2/gpufilters.hpp
+11
-6
modules/gpufilters/src/filtering.cpp
modules/gpufilters/src/filtering.cpp
+95
-62
未找到文件。
modules/gpufilters/include/opencv2/gpufilters.hpp
浏览文件 @
4bb297af
...
@@ -241,7 +241,18 @@ inline void morphologyEx(InputArray src, OutputArray dst, int op, InputArray ker
...
@@ -241,7 +241,18 @@ inline void morphologyEx(InputArray src, OutputArray dst, int op, InputArray ker
f
->
apply
(
src
,
dst
,
stream
);
f
->
apply
(
src
,
dst
,
stream
);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Image Rank Filter
//! Result pixel value is the maximum of pixel values under the rectangular mask region
CV_EXPORTS
Ptr
<
Filter
>
createBoxMaxFilter
(
int
srcType
,
Size
ksize
,
Point
anchor
=
Point
(
-
1
,
-
1
),
int
borderMode
=
BORDER_DEFAULT
,
Scalar
borderVal
=
Scalar
::
all
(
0
));
//! Result pixel value is the maximum of pixel values under the rectangular mask region
CV_EXPORTS
Ptr
<
Filter
>
createBoxMinFilter
(
int
srcType
,
Size
ksize
,
Point
anchor
=
Point
(
-
1
,
-
1
),
int
borderMode
=
BORDER_DEFAULT
,
Scalar
borderVal
=
Scalar
::
all
(
0
));
...
@@ -326,12 +337,6 @@ CV_EXPORTS Ptr<BaseColumnFilter_GPU> getColumnSumFilter_GPU(int sumType, int dst
...
@@ -326,12 +337,6 @@ CV_EXPORTS Ptr<BaseColumnFilter_GPU> getColumnSumFilter_GPU(int sumType, int dst
//! returns maximum filter
CV_EXPORTS
Ptr
<
BaseFilter_GPU
>
getMaxFilter_GPU
(
int
srcType
,
int
dstType
,
const
Size
&
ksize
,
Point
anchor
=
Point
(
-
1
,
-
1
));
//! returns minimum filter
CV_EXPORTS
Ptr
<
BaseFilter_GPU
>
getMinFilter_GPU
(
int
srcType
,
int
dstType
,
const
Size
&
ksize
,
Point
anchor
=
Point
(
-
1
,
-
1
));
...
...
modules/gpufilters/src/filtering.cpp
浏览文件 @
4bb297af
...
@@ -63,6 +63,8 @@ Ptr<Filter> cv::gpu::createGaussianFilter(int, int, Size, double, double, int, i
...
@@ -63,6 +63,8 @@ Ptr<Filter> cv::gpu::createGaussianFilter(int, int, Size, double, double, int, i
Ptr
<
Filter
>
cv
::
gpu
::
createMorphologyFilter
(
int
,
int
,
InputArray
,
Point
,
int
)
{
throw_no_cuda
();
return
Ptr
<
Filter
>
();
}
Ptr
<
Filter
>
cv
::
gpu
::
createMorphologyFilter
(
int
,
int
,
InputArray
,
Point
,
int
)
{
throw_no_cuda
();
return
Ptr
<
Filter
>
();
}
Ptr
<
Filter
>
cv
::
gpu
::
createBoxMaxFilter
(
int
,
Size
,
Point
,
int
,
Scalar
)
{
throw_no_cuda
();
return
Ptr
<
Filter
>
();
}
Ptr
<
Filter
>
cv
::
gpu
::
createBoxMinFilter
(
int
,
Size
,
Point
,
int
,
Scalar
)
{
throw_no_cuda
();
return
Ptr
<
Filter
>
();
}
...
@@ -70,8 +72,6 @@ Ptr<Filter> cv::gpu::createMorphologyFilter(int, int, InputArray, Point, int) {
...
@@ -70,8 +72,6 @@ Ptr<Filter> cv::gpu::createMorphologyFilter(int, int, InputArray, Point, int) {
Ptr
<
BaseRowFilter_GPU
>
cv
::
gpu
::
getRowSumFilter_GPU
(
int
,
int
,
int
,
int
)
{
throw_no_cuda
();
return
Ptr
<
BaseRowFilter_GPU
>
(
0
);
}
Ptr
<
BaseRowFilter_GPU
>
cv
::
gpu
::
getRowSumFilter_GPU
(
int
,
int
,
int
,
int
)
{
throw_no_cuda
();
return
Ptr
<
BaseRowFilter_GPU
>
(
0
);
}
Ptr
<
BaseColumnFilter_GPU
>
cv
::
gpu
::
getColumnSumFilter_GPU
(
int
,
int
,
int
,
int
)
{
throw_no_cuda
();
return
Ptr
<
BaseColumnFilter_GPU
>
(
0
);
}
Ptr
<
BaseColumnFilter_GPU
>
cv
::
gpu
::
getColumnSumFilter_GPU
(
int
,
int
,
int
,
int
)
{
throw_no_cuda
();
return
Ptr
<
BaseColumnFilter_GPU
>
(
0
);
}
Ptr
<
BaseFilter_GPU
>
cv
::
gpu
::
getMaxFilter_GPU
(
int
,
int
,
const
Size
&
,
Point
)
{
throw_no_cuda
();
return
Ptr
<
BaseFilter_GPU
>
(
0
);
}
Ptr
<
BaseFilter_GPU
>
cv
::
gpu
::
getMinFilter_GPU
(
int
,
int
,
const
Size
&
,
Point
)
{
throw_no_cuda
();
return
Ptr
<
BaseFilter_GPU
>
(
0
);
}
...
@@ -783,6 +783,99 @@ Ptr<Filter> cv::gpu::createMorphologyFilter(int op, int srcType, InputArray kern
...
@@ -783,6 +783,99 @@ Ptr<Filter> cv::gpu::createMorphologyFilter(int op, int srcType, InputArray kern
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Image Rank Filter
namespace
{
enum
{
RANK_MAX
,
RANK_MIN
};
class
NPPRankFilter
:
public
Filter
{
public:
NPPRankFilter
(
int
op
,
int
srcType
,
Size
ksize
,
Point
anchor
,
int
borderMode
,
Scalar
borderVal
);
void
apply
(
InputArray
src
,
OutputArray
dst
,
Stream
&
stream
=
Stream
::
Null
());
private:
typedef
NppStatus
(
*
nppFilterRank_t
)(
const
Npp8u
*
pSrc
,
Npp32s
nSrcStep
,
Npp8u
*
pDst
,
Npp32s
nDstStep
,
NppiSize
oSizeROI
,
NppiSize
oMaskSize
,
NppiPoint
oAnchor
);
int
type_
;
Size
ksize_
;
Point
anchor_
;
int
borderMode_
;
Scalar
borderVal_
;
nppFilterRank_t
func_
;
GpuMat
srcBorder_
;
};
NPPRankFilter
::
NPPRankFilter
(
int
op
,
int
srcType
,
Size
ksize
,
Point
anchor
,
int
borderMode
,
Scalar
borderVal
)
:
type_
(
srcType
),
ksize_
(
ksize
),
anchor_
(
anchor
),
borderMode_
(
borderMode
),
borderVal_
(
borderVal
)
{
static
const
nppFilterRank_t
maxFuncs
[]
=
{
0
,
nppiFilterMax_8u_C1R
,
0
,
0
,
nppiFilterMax_8u_C4R
};
static
const
nppFilterRank_t
minFuncs
[]
=
{
0
,
nppiFilterMin_8u_C1R
,
0
,
0
,
nppiFilterMin_8u_C4R
};
CV_Assert
(
srcType
==
CV_8UC1
||
srcType
==
CV_8UC4
);
normalizeAnchor
(
anchor_
,
ksize_
);
if
(
op
==
RANK_MAX
)
func_
=
maxFuncs
[
CV_MAT_CN
(
srcType
)];
else
func_
=
minFuncs
[
CV_MAT_CN
(
srcType
)];
}
void
NPPRankFilter
::
apply
(
InputArray
_src
,
OutputArray
_dst
,
Stream
&
_stream
)
{
GpuMat
src
=
_src
.
getGpuMat
();
CV_Assert
(
src
.
type
()
==
type_
);
gpu
::
copyMakeBorder
(
src
,
srcBorder_
,
ksize_
.
height
,
ksize_
.
height
,
ksize_
.
width
,
ksize_
.
width
,
borderMode_
,
borderVal_
,
_stream
);
_dst
.
create
(
src
.
size
(),
src
.
type
());
GpuMat
dst
=
_dst
.
getGpuMat
();
GpuMat
srcRoi
=
srcBorder_
(
Rect
(
ksize_
.
width
,
ksize_
.
height
,
src
.
cols
,
src
.
rows
));
cudaStream_t
stream
=
StreamAccessor
::
getStream
(
_stream
);
NppStreamHandler
h
(
stream
);
NppiSize
oSizeROI
;
oSizeROI
.
width
=
src
.
cols
;
oSizeROI
.
height
=
src
.
rows
;
NppiSize
oMaskSize
;
oMaskSize
.
height
=
ksize_
.
height
;
oMaskSize
.
width
=
ksize_
.
width
;
NppiPoint
oAnchor
;
oAnchor
.
x
=
anchor_
.
x
;
oAnchor
.
y
=
anchor_
.
y
;
nppSafeCall
(
func_
(
srcRoi
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
srcRoi
.
step
),
dst
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
dst
.
step
),
oSizeROI
,
oMaskSize
,
oAnchor
)
);
if
(
stream
==
0
)
cudaSafeCall
(
cudaDeviceSynchronize
()
);
}
}
Ptr
<
Filter
>
cv
::
gpu
::
createBoxMaxFilter
(
int
srcType
,
Size
ksize
,
Point
anchor
,
int
borderMode
,
Scalar
borderVal
)
{
return
new
NPPRankFilter
(
RANK_MAX
,
srcType
,
ksize
,
anchor
,
borderMode
,
borderVal
);
}
Ptr
<
Filter
>
cv
::
gpu
::
createBoxMinFilter
(
int
srcType
,
Size
ksize
,
Point
anchor
,
int
borderMode
,
Scalar
borderVal
)
{
return
new
NPPRankFilter
(
RANK_MIN
,
srcType
,
ksize
,
anchor
,
borderMode
,
borderVal
);
}
...
@@ -924,64 +1017,4 @@ Ptr<BaseColumnFilter_GPU> cv::gpu::getColumnSumFilter_GPU(int sumType, int dstTy
...
@@ -924,64 +1017,4 @@ Ptr<BaseColumnFilter_GPU> cv::gpu::getColumnSumFilter_GPU(int sumType, int dstTy
////////////////////////////////////////////////////////////////////////////////////////////////////
// Image Rank Filter
namespace
{
typedef
NppStatus
(
*
nppFilterRank_t
)(
const
Npp8u
*
pSrc
,
Npp32s
nSrcStep
,
Npp8u
*
pDst
,
Npp32s
nDstStep
,
NppiSize
oSizeROI
,
NppiSize
oMaskSize
,
NppiPoint
oAnchor
);
struct
NPPRankFilter
:
public
BaseFilter_GPU
{
NPPRankFilter
(
const
Size
&
ksize_
,
const
Point
&
anchor_
,
nppFilterRank_t
func_
)
:
BaseFilter_GPU
(
ksize_
,
anchor_
),
func
(
func_
)
{}
virtual
void
operator
()(
const
GpuMat
&
src
,
GpuMat
&
dst
,
Stream
&
s
=
Stream
::
Null
())
{
NppiSize
sz
;
sz
.
width
=
src
.
cols
;
sz
.
height
=
src
.
rows
;
NppiSize
oKernelSize
;
oKernelSize
.
height
=
ksize
.
height
;
oKernelSize
.
width
=
ksize
.
width
;
NppiPoint
oAnchor
;
oAnchor
.
x
=
anchor
.
x
;
oAnchor
.
y
=
anchor
.
y
;
cudaStream_t
stream
=
StreamAccessor
::
getStream
(
s
);
NppStreamHandler
h
(
stream
);
nppSafeCall
(
func
(
src
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
src
.
step
),
dst
.
ptr
<
Npp8u
>
(),
static_cast
<
int
>
(
dst
.
step
),
sz
,
oKernelSize
,
oAnchor
)
);
if
(
stream
==
0
)
cudaSafeCall
(
cudaDeviceSynchronize
()
);
}
nppFilterRank_t
func
;
};
}
Ptr
<
BaseFilter_GPU
>
cv
::
gpu
::
getMaxFilter_GPU
(
int
srcType
,
int
dstType
,
const
Size
&
ksize
,
Point
anchor
)
{
static
const
nppFilterRank_t
nppFilterRank_callers
[]
=
{
0
,
nppiFilterMax_8u_C1R
,
0
,
0
,
nppiFilterMax_8u_C4R
};
CV_Assert
((
srcType
==
CV_8UC1
||
srcType
==
CV_8UC4
)
&&
dstType
==
srcType
);
normalizeAnchor
(
anchor
,
ksize
);
return
Ptr
<
BaseFilter_GPU
>
(
new
NPPRankFilter
(
ksize
,
anchor
,
nppFilterRank_callers
[
CV_MAT_CN
(
srcType
)]));
}
Ptr
<
BaseFilter_GPU
>
cv
::
gpu
::
getMinFilter_GPU
(
int
srcType
,
int
dstType
,
const
Size
&
ksize
,
Point
anchor
)
{
static
const
nppFilterRank_t
nppFilterRank_callers
[]
=
{
0
,
nppiFilterMin_8u_C1R
,
0
,
0
,
nppiFilterMin_8u_C4R
};
CV_Assert
((
srcType
==
CV_8UC1
||
srcType
==
CV_8UC4
)
&&
dstType
==
srcType
);
normalizeAnchor
(
anchor
,
ksize
);
return
Ptr
<
BaseFilter_GPU
>
(
new
NPPRankFilter
(
ksize
,
anchor
,
nppFilterRank_callers
[
CV_MAT_CN
(
srcType
)]));
}
#endif
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录