Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
cba926a4
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,发现更多精彩内容 >>
提交
cba926a4
编写于
7月 28, 2010
作者:
M
Maria Dimashova
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added c++ interface for cvPyrMeanShiftFiltering; added sample on meanshift segmentation
上级
69ef5efb
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
83 addition
and
1 deletion
+83
-1
modules/features2d/src/calonder.cpp
modules/features2d/src/calonder.cpp
+1
-1
modules/imgproc/include/opencv2/imgproc/imgproc.hpp
modules/imgproc/include/opencv2/imgproc/imgproc.hpp
+5
-0
modules/imgproc/src/segmentation.cpp
modules/imgproc/src/segmentation.cpp
+11
-0
samples/cpp/meanshift_segmentation.cpp
samples/cpp/meanshift_segmentation.cpp
+66
-0
未找到文件。
modules/features2d/src/calonder.cpp
浏览文件 @
cba926a4
...
...
@@ -333,7 +333,7 @@ void RandomizedTree::train(std::vector<BaseKeypoint> const& base_set,
Size
patchSize
(
PATCH_SIZE
,
PATCH_SIZE
);
for
(
keypt_it
=
base_set
.
begin
();
keypt_it
!=
base_set
.
end
();
++
keypt_it
,
++
class_id
)
{
for
(
int
i
=
0
;
i
<
views
;
++
i
)
{
make_patch
(
Mat
(
keypt_it
->
image
),
Point
(
keypt_it
->
y
,
keypt_it
->
x
),
patch
,
patchSize
,
rng
);
make_patch
(
Mat
(
keypt_it
->
image
),
Point
(
keypt_it
->
x
,
keypt_it
->
y
),
patch
,
patchSize
,
rng
);
IplImage
iplPatch
=
patch
;
addExample
(
class_id
,
getData
(
&
iplPatch
));
}
...
...
modules/imgproc/include/opencv2/imgproc/imgproc.hpp
浏览文件 @
cba926a4
...
...
@@ -653,6 +653,11 @@ CV_EXPORTS void equalizeHist( const Mat& src, Mat& dst );
//! segments the image using watershed algorithm
CV_EXPORTS
void
watershed
(
const
Mat
&
image
,
Mat
&
markers
);
//! filters image using meanshift algorithm
CV_EXPORTS
void
pyrMeanShiftFiltering
(
const
Mat
&
src
,
Mat
&
dst
,
double
sp
,
double
sr
,
int
maxLevel
=
1
,
TermCriteria
termcrit
=
TermCriteria
(
TermCriteria
::
MAX_ITER
+
TermCriteria
::
EPS
,
5
,
1
)
);
//! class of the pixel in GrabCut algorithm
enum
{
GC_BGD
=
0
,
//!< background
GC_FGD
=
1
,
//!< foreground
...
...
modules/imgproc/src/segmentation.cpp
浏览文件 @
cba926a4
...
...
@@ -526,3 +526,14 @@ cvPyrMeanShiftFiltering( const CvArr* srcarr, CvArr* dstarr,
}
}
void
cv
::
pyrMeanShiftFiltering
(
const
Mat
&
src
,
Mat
&
dst
,
double
sp
,
double
sr
,
int
maxLevel
,
TermCriteria
termcrit
)
{
if
(
src
.
empty
()
)
return
;
dst
.
create
(
src
.
size
(),
src
.
type
()
);
CvMat
_src
=
src
,
_dst
=
dst
;
cvPyrMeanShiftFiltering
(
&
_src
,
&
_dst
,
sp
,
sr
,
maxLevel
,
termcrit
);
}
samples/cpp/meanshift_segmentation.cpp
0 → 100644
浏览文件 @
cba926a4
#include <highgui.h>
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using
namespace
cv
;
using
namespace
std
;
void
floodFillPostprocess
(
Mat
&
img
,
const
Scalar
&
colorDiff
=
Scalar
::
all
(
1
)
)
{
CV_Assert
(
!
img
.
empty
()
);
RNG
rng
=
theRNG
();
Mat
mask
(
img
.
rows
+
2
,
img
.
cols
+
2
,
CV_8UC1
,
Scalar
::
all
(
0
)
);
for
(
int
y
=
0
;
y
<
img
.
rows
;
y
++
)
{
for
(
int
x
=
0
;
x
<
img
.
cols
;
x
++
)
{
if
(
mask
.
at
<
uchar
>
(
y
+
1
,
x
+
1
)
==
0
)
{
Scalar
newVal
(
rng
(
256
),
rng
(
256
),
rng
(
256
)
);
floodFill
(
img
,
mask
,
Point
(
x
,
y
),
newVal
,
0
,
colorDiff
,
colorDiff
);
}
}
}
}
string
winName
=
"meanshift"
;
int
spatialRad
,
colorRad
,
maxPyrLevel
;
Mat
img
,
res
;
void
meanShiftSegmentation
(
int
,
void
*
)
{
cout
<<
"spatialRad="
<<
spatialRad
<<
"; "
<<
"colorRad="
<<
colorRad
<<
"; "
<<
"maxPyrLevel="
<<
maxPyrLevel
<<
endl
;
pyrMeanShiftFiltering
(
img
,
res
,
spatialRad
,
colorRad
,
maxPyrLevel
);
floodFillPostprocess
(
res
,
Scalar
::
all
(
2
)
);
imshow
(
winName
,
res
);
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
2
)
{
cout
<<
"Format:"
<<
endl
<<
argv
[
0
]
<<
" image"
<<
endl
;
return
-
1
;
}
img
=
imread
(
argv
[
1
]
);
if
(
img
.
empty
()
)
return
-
1
;
spatialRad
=
10
;
colorRad
=
10
;
maxPyrLevel
=
1
;
namedWindow
(
winName
,
CV_WINDOW_AUTOSIZE
);
createTrackbar
(
"spatialRad"
,
winName
,
&
spatialRad
,
80
,
meanShiftSegmentation
);
createTrackbar
(
"colorRad"
,
winName
,
&
colorRad
,
60
,
meanShiftSegmentation
);
createTrackbar
(
"maxPyrLevel"
,
winName
,
&
maxPyrLevel
,
5
,
meanShiftSegmentation
);
meanShiftSegmentation
(
0
,
0
);
waitKey
();
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录