Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
0cb1e964
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,发现更多精彩内容 >>
提交
0cb1e964
编写于
5月 25, 2016
作者:
V
Vadim Pisarevsky
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6546 from atinfinity:pullreq/160517-threshold-64F
上级
0fc26f80
1f1464c9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
140 addition
and
11 deletion
+140
-11
modules/imgproc/src/thresh.cpp
modules/imgproc/src/thresh.cpp
+85
-0
modules/imgproc/test/test_thresh.cpp
modules/imgproc/test/test_thresh.cpp
+55
-11
未找到文件。
modules/imgproc/src/thresh.cpp
浏览文件 @
0cb1e964
...
...
@@ -904,6 +904,85 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type )
}
}
static
void
thresh_64f
(
const
Mat
&
_src
,
Mat
&
_dst
,
double
thresh
,
double
maxval
,
int
type
)
{
int
i
,
j
;
Size
roi
=
_src
.
size
();
roi
.
width
*=
_src
.
channels
();
const
double
*
src
=
_src
.
ptr
<
double
>
();
double
*
dst
=
_dst
.
ptr
<
double
>
();
size_t
src_step
=
_src
.
step
/
sizeof
(
src
[
0
]);
size_t
dst_step
=
_dst
.
step
/
sizeof
(
dst
[
0
]);
if
(
_src
.
isContinuous
()
&&
_dst
.
isContinuous
())
{
roi
.
width
*=
roi
.
height
;
roi
.
height
=
1
;
}
switch
(
type
)
{
case
THRESH_BINARY
:
for
(
i
=
0
;
i
<
roi
.
height
;
i
++
,
src
+=
src_step
,
dst
+=
dst_step
)
{
j
=
0
;
for
(;
j
<
roi
.
width
;
j
++
)
dst
[
j
]
=
src
[
j
]
>
thresh
?
maxval
:
0
;
}
break
;
case
THRESH_BINARY_INV
:
for
(
i
=
0
;
i
<
roi
.
height
;
i
++
,
src
+=
src_step
,
dst
+=
dst_step
)
{
j
=
0
;
for
(;
j
<
roi
.
width
;
j
++
)
dst
[
j
]
=
src
[
j
]
<=
thresh
?
maxval
:
0
;
}
break
;
case
THRESH_TRUNC
:
for
(
i
=
0
;
i
<
roi
.
height
;
i
++
,
src
+=
src_step
,
dst
+=
dst_step
)
{
j
=
0
;
for
(;
j
<
roi
.
width
;
j
++
)
dst
[
j
]
=
std
::
min
(
src
[
j
],
thresh
);
}
break
;
case
THRESH_TOZERO
:
for
(
i
=
0
;
i
<
roi
.
height
;
i
++
,
src
+=
src_step
,
dst
+=
dst_step
)
{
j
=
0
;
for
(;
j
<
roi
.
width
;
j
++
)
{
double
v
=
src
[
j
];
dst
[
j
]
=
v
>
thresh
?
v
:
0
;
}
}
break
;
case
THRESH_TOZERO_INV
:
for
(
i
=
0
;
i
<
roi
.
height
;
i
++
,
src
+=
src_step
,
dst
+=
dst_step
)
{
j
=
0
;
for
(;
j
<
roi
.
width
;
j
++
)
{
double
v
=
src
[
j
];
dst
[
j
]
=
v
<=
thresh
?
v
:
0
;
}
}
break
;
default:
return
CV_Error
(
CV_StsBadArg
,
""
);
}
}
#ifdef HAVE_IPP
static
bool
ipp_getThreshVal_Otsu_8u
(
const
unsigned
char
*
_src
,
int
step
,
Size
size
,
unsigned
char
&
thresh
)
{
...
...
@@ -1129,6 +1208,10 @@ public:
{
thresh_32f
(
srcStripe
,
dstStripe
,
(
float
)
thresh
,
(
float
)
maxval
,
thresholdType
);
}
else
if
(
srcStripe
.
depth
()
==
CV_64F
)
{
thresh_64f
(
srcStripe
,
dstStripe
,
thresh
,
maxval
,
thresholdType
);
}
}
private:
...
...
@@ -1269,6 +1352,8 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
}
else
if
(
src
.
depth
()
==
CV_32F
)
;
else
if
(
src
.
depth
()
==
CV_64F
)
;
else
CV_Error
(
CV_StsUnsupportedFormat
,
""
);
...
...
modules/imgproc/test/test_thresh.cpp
浏览文件 @
0cb1e964
...
...
@@ -56,8 +56,8 @@ protected:
void
prepare_to_validation
(
int
);
int
thresh_type
;
float
thresh_val
;
float
max_val
;
double
thresh_val
;
double
max_val
;
};
...
...
@@ -120,7 +120,7 @@ void CV_ThreshTest::run_func()
static
void
test_threshold
(
const
Mat
&
_src
,
Mat
&
_dst
,
float
thresh
,
float
maxval
,
int
thresh_type
)
double
thresh
,
double
maxval
,
int
thresh_type
)
{
int
i
,
j
;
int
depth
=
_src
.
depth
(),
cn
=
_src
.
channels
();
...
...
@@ -144,7 +144,7 @@ static void test_threshold( const Mat& _src, Mat& _dst,
imaxval
=
cvRound
(
maxval
);
}
assert
(
depth
==
CV_8U
||
depth
==
CV_16S
||
depth
==
CV_32F
);
assert
(
depth
==
CV_8U
||
depth
==
CV_16S
||
depth
==
CV_32F
||
depth
==
CV_64F
);
switch
(
thresh_type
)
{
...
...
@@ -165,12 +165,19 @@ static void test_threshold( const Mat& _src, Mat& _dst,
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
(
short
)(
src
[
j
]
>
ithresh
?
imaxval
:
0
);
}
else
else
if
(
depth
==
CV_32F
)
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
float
*
dst
=
_dst
.
ptr
<
float
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
src
[
j
]
>
thresh
?
maxval
:
0.
f
;
dst
[
j
]
=
(
float
)(
src
[
j
]
>
thresh
?
maxval
:
0.
f
);
}
else
{
const
double
*
src
=
_src
.
ptr
<
double
>
(
i
);
double
*
dst
=
_dst
.
ptr
<
double
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
src
[
j
]
>
thresh
?
maxval
:
0.0
;
}
}
break
;
...
...
@@ -191,12 +198,19 @@ static void test_threshold( const Mat& _src, Mat& _dst,
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
(
short
)(
src
[
j
]
>
ithresh
?
0
:
imaxval
);
}
else
else
if
(
depth
==
CV_32F
)
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
float
*
dst
=
_dst
.
ptr
<
float
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
src
[
j
]
>
thresh
?
0.
f
:
maxval
;
dst
[
j
]
=
(
float
)(
src
[
j
]
>
thresh
?
0.
f
:
maxval
);
}
else
{
const
double
*
src
=
_src
.
ptr
<
double
>
(
i
);
double
*
dst
=
_dst
.
ptr
<
double
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
src
[
j
]
>
thresh
?
0.0
:
maxval
;
}
}
break
;
...
...
@@ -223,13 +237,23 @@ static void test_threshold( const Mat& _src, Mat& _dst,
dst
[
j
]
=
(
short
)(
s
>
ithresh
?
ithresh2
:
s
);
}
}
else
else
if
(
depth
==
CV_32F
)
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
float
*
dst
=
_dst
.
ptr
<
float
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
float
s
=
src
[
j
];
dst
[
j
]
=
(
float
)(
s
>
thresh
?
thresh
:
s
);
}
}
else
{
const
double
*
src
=
_src
.
ptr
<
double
>
(
i
);
double
*
dst
=
_dst
.
ptr
<
double
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
double
s
=
src
[
j
];
dst
[
j
]
=
s
>
thresh
?
thresh
:
s
;
}
}
...
...
@@ -258,7 +282,7 @@ static void test_threshold( const Mat& _src, Mat& _dst,
dst
[
j
]
=
(
short
)(
s
>
ithresh
?
s
:
0
);
}
}
else
else
if
(
depth
==
CV_32F
)
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
float
*
dst
=
_dst
.
ptr
<
float
>
(
i
);
...
...
@@ -268,6 +292,16 @@ static void test_threshold( const Mat& _src, Mat& _dst,
dst
[
j
]
=
s
>
thresh
?
s
:
0.
f
;
}
}
else
{
const
double
*
src
=
_src
.
ptr
<
double
>
(
i
);
double
*
dst
=
_dst
.
ptr
<
double
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
double
s
=
src
[
j
];
dst
[
j
]
=
s
>
thresh
?
s
:
0.0
;
}
}
}
break
;
case
CV_THRESH_TOZERO_INV
:
...
...
@@ -293,7 +327,7 @@ static void test_threshold( const Mat& _src, Mat& _dst,
dst
[
j
]
=
(
short
)(
s
>
ithresh
?
0
:
s
);
}
}
else
else
if
(
depth
==
CV_32F
)
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
float
*
dst
=
_dst
.
ptr
<
float
>
(
i
);
...
...
@@ -303,6 +337,16 @@ static void test_threshold( const Mat& _src, Mat& _dst,
dst
[
j
]
=
s
>
thresh
?
0.
f
:
s
;
}
}
else
{
const
double
*
src
=
_src
.
ptr
<
double
>
(
i
);
double
*
dst
=
_dst
.
ptr
<
double
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
double
s
=
src
[
j
];
dst
[
j
]
=
s
>
thresh
?
0.0
:
s
;
}
}
}
break
;
default:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录