Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
72d2311e
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
72d2311e
编写于
5月 29, 2012
作者:
V
Vladislav Vinogradov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merged revision(s) 8495 from trunk:
Bug #1991 : fixed gpu interpolation (remap, resize, warp...) ........
上级
d382fa56
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
68 addition
and
41 deletion
+68
-41
modules/gpu/src/opencv2/gpu/device/filters.hpp
modules/gpu/src/opencv2/gpu/device/filters.hpp
+34
-14
modules/gpu/test/interpolation.hpp
modules/gpu/test/interpolation.hpp
+33
-26
modules/gpu/test/test_remap.cpp
modules/gpu/test/test_remap.cpp
+1
-1
未找到文件。
modules/gpu/src/opencv2/gpu/device/filters.hpp
浏览文件 @
72d2311e
...
...
@@ -59,7 +59,7 @@ namespace cv { namespace gpu { namespace device
__device__
__forceinline__
elem_type
operator
()(
float
y
,
float
x
)
const
{
return
src
(
__float2int_r
d
(
y
),
__float2int_rd
(
x
));
return
src
(
__float2int_r
n
(
y
),
__float2int_rn
(
x
));
}
const
Ptr2D
src
;
...
...
@@ -78,9 +78,6 @@ namespace cv { namespace gpu { namespace device
work_type
out
=
VecTraits
<
work_type
>::
all
(
0
);
x
-=
0.5
f
;
y
-=
0.5
f
;
const
int
x1
=
__float2int_rd
(
x
);
const
int
y1
=
__float2int_rd
(
y
);
const
int
x2
=
x1
+
1
;
...
...
@@ -112,24 +109,47 @@ namespace cv { namespace gpu { namespace device
explicit
__host__
__device__
__forceinline__
CubicFilter
(
const
Ptr2D
&
src_
)
:
src
(
src_
)
{}
static
__device__
__forceinline__
work_type
cubicInterpolate
(
typename
TypeTraits
<
work_type
>::
ParameterType
p0
,
typename
TypeTraits
<
work_type
>::
ParameterType
p1
,
typename
TypeTraits
<
work_type
>::
ParameterType
p2
,
typename
TypeTraits
<
work_type
>::
ParameterType
p3
,
float
x
)
static
__device__
__forceinline__
float
bicubicCoeff
(
float
x_
)
{
return
p1
+
0.5
f
*
x
*
(
p2
-
p0
+
x
*
(
2.0
f
*
p0
-
5.0
f
*
p1
+
4.0
f
*
p2
-
p3
+
x
*
(
3.0
f
*
(
p1
-
p2
)
+
p3
-
p0
)));
float
x
=
fabsf
(
x_
);
if
(
x
<=
1.0
f
)
{
return
x
*
x
*
(
1.5
f
*
x
-
2.5
f
)
+
1.0
f
;
}
else
if
(
x
<
2.0
f
)
{
return
x
*
(
x
*
(
-
0.5
f
*
x
+
2.5
f
)
-
4.0
f
)
+
2.0
f
;
}
else
{
return
0.0
f
;
}
}
__device__
elem_type
operator
()(
float
y
,
float
x
)
const
{
const
int
xi
=
__float2int_rn
(
x
);
const
int
yi
=
__float2int_rn
(
y
);
const
float
xmin
=
::
ceilf
(
x
-
2.0
f
);
const
float
xmax
=
::
floorf
(
x
+
2.0
f
);
const
float
ymin
=
::
ceilf
(
y
-
2.0
f
);
const
float
ymax
=
::
floorf
(
y
+
2.0
f
);
work_type
sum
=
VecTraits
<
work_type
>::
all
(
0
);
float
wsum
=
0.0
f
;
work_type
arr
[
4
];
for
(
float
cy
=
ymin
;
cy
<=
ymax
;
cy
+=
1.0
f
)
{
for
(
float
cx
=
xmin
;
cx
<=
xmax
;
cx
+=
1.0
f
)
{
const
float
w
=
bicubicCoeff
(
x
-
cx
)
*
bicubicCoeff
(
y
-
cy
);
sum
=
sum
+
w
*
src
(
__float2int_rd
(
cy
),
__float2int_rd
(
cx
));
wsum
+=
w
;
}
}
arr
[
0
]
=
cubicInterpolate
(
saturate_cast
<
work_type
>
(
src
(
yi
-
2
,
xi
-
2
)),
saturate_cast
<
work_type
>
(
src
(
yi
-
2
,
xi
-
1
)),
saturate_cast
<
work_type
>
(
src
(
yi
-
2
,
xi
)),
saturate_cast
<
work_type
>
(
src
(
yi
-
2
,
xi
+
1
)),
(
x
-
xi
+
2.0
f
)
/
4.0
f
);
arr
[
1
]
=
cubicInterpolate
(
saturate_cast
<
work_type
>
(
src
(
yi
-
1
,
xi
-
2
)),
saturate_cast
<
work_type
>
(
src
(
yi
-
1
,
xi
-
1
)),
saturate_cast
<
work_type
>
(
src
(
yi
-
1
,
xi
)),
saturate_cast
<
work_type
>
(
src
(
yi
-
1
,
xi
+
1
)),
(
x
-
xi
+
2.0
f
)
/
4.0
f
);
arr
[
2
]
=
cubicInterpolate
(
saturate_cast
<
work_type
>
(
src
(
yi
,
xi
-
2
)),
saturate_cast
<
work_type
>
(
src
(
yi
,
xi
-
1
)),
saturate_cast
<
work_type
>
(
src
(
yi
,
xi
)),
saturate_cast
<
work_type
>
(
src
(
yi
,
xi
+
1
)),
(
x
-
xi
+
2.0
f
)
/
4.0
f
);
arr
[
3
]
=
cubicInterpolate
(
saturate_cast
<
work_type
>
(
src
(
yi
+
1
,
xi
-
2
)),
saturate_cast
<
work_type
>
(
src
(
yi
+
1
,
xi
-
1
)),
saturate_cast
<
work_type
>
(
src
(
yi
+
1
,
xi
)),
saturate_cast
<
work_type
>
(
src
(
yi
+
1
,
xi
+
1
)),
(
x
-
xi
+
2.0
f
)
/
4.0
f
);
work_type
res
=
(
!
wsum
)
?
VecTraits
<
work_type
>::
all
(
0
)
:
sum
/
wsum
;
return
saturate_cast
<
elem_type
>
(
cubicInterpolate
(
arr
[
0
],
arr
[
1
],
arr
[
2
],
arr
[
3
],
(
y
-
yi
+
2.0
f
)
/
4.0
f
)
);
return
saturate_cast
<
elem_type
>
(
res
);
}
const
Ptr2D
src
;
...
...
modules/gpu/test/interpolation.hpp
浏览文件 @
72d2311e
...
...
@@ -54,7 +54,7 @@ template <typename T> struct NearestInterpolator
{
static
T
getValue
(
const
cv
::
Mat
&
src
,
float
y
,
float
x
,
int
c
,
int
border_type
,
cv
::
Scalar
borderVal
=
cv
::
Scalar
())
{
return
readVal
<
T
>
(
src
,
cv
Floor
(
y
),
cvFloor
(
x
),
c
,
border_type
,
borderVal
);
return
readVal
<
T
>
(
src
,
cv
Round
(
y
),
cvRound
(
x
),
c
,
border_type
,
borderVal
);
}
};
...
...
@@ -62,9 +62,6 @@ template <typename T> struct LinearInterpolator
{
static
T
getValue
(
const
cv
::
Mat
&
src
,
float
y
,
float
x
,
int
c
,
int
border_type
,
cv
::
Scalar
borderVal
=
cv
::
Scalar
())
{
x
-=
0.5
f
;
y
-=
0.5
f
;
int
x1
=
cvFloor
(
x
);
int
y1
=
cvFloor
(
y
);
int
x2
=
x1
+
1
;
...
...
@@ -83,37 +80,47 @@ template <typename T> struct LinearInterpolator
template
<
typename
T
>
struct
CubicInterpolator
{
static
float
getValue
(
float
p
[
4
],
float
x
)
static
float
bicubicCoeff
(
float
x_
)
{
return
static_cast
<
float
>
(
p
[
1
]
+
0.5
*
x
*
(
p
[
2
]
-
p
[
0
]
+
x
*
(
2.0
*
p
[
0
]
-
5.0
*
p
[
1
]
+
4.0
*
p
[
2
]
-
p
[
3
]
+
x
*
(
3.0
*
(
p
[
1
]
-
p
[
2
])
+
p
[
3
]
-
p
[
0
]))));
float
x
=
fabsf
(
x_
);
if
(
x
<=
1.0
f
)
{
return
x
*
x
*
(
1.5
f
*
x
-
2.5
f
)
+
1.0
f
;
}
else
if
(
x
<
2.0
f
)
{
return
x
*
(
x
*
(
-
0.5
f
*
x
+
2.5
f
)
-
4.0
f
)
+
2.0
f
;
}
else
{
return
0.0
f
;
}
}
static
float
getValue
(
float
p
[
4
][
4
],
float
x
,
float
y
)
static
T
getValue
(
const
cv
::
Mat
&
src
,
float
y
,
float
x
,
int
c
,
int
border_type
,
cv
::
Scalar
borderVal
=
cv
::
Scalar
()
)
{
float
arr
[
4
];
const
float
xmin
=
ceilf
(
x
-
2.0
f
);
const
float
xmax
=
floorf
(
x
+
2.0
f
);
arr
[
0
]
=
getValue
(
p
[
0
],
x
);
arr
[
1
]
=
getValue
(
p
[
1
],
x
);
arr
[
2
]
=
getValue
(
p
[
2
],
x
);
arr
[
3
]
=
getValue
(
p
[
3
],
x
);
const
float
ymin
=
ceilf
(
y
-
2.0
f
);
const
float
ymax
=
floorf
(
y
+
2.0
f
);
return
getValue
(
arr
,
y
)
;
}
float
sum
=
0.0
f
;
float
wsum
=
0.0
f
;
static
T
getValue
(
const
cv
::
Mat
&
src
,
float
y
,
float
x
,
int
c
,
int
border_type
,
cv
::
Scalar
borderVal
=
cv
::
Scalar
())
{
int
ix
=
cvRound
(
x
);
int
iy
=
cvRound
(
y
);
float
vals
[
4
][
4
]
=
for
(
float
cy
=
ymin
;
cy
<=
ymax
;
cy
+=
1.0
f
)
{
{(
float
)
readVal
<
T
>
(
src
,
iy
-
2
,
ix
-
2
,
c
,
border_type
,
borderVal
),
(
float
)
readVal
<
T
>
(
src
,
iy
-
2
,
ix
-
1
,
c
,
border_type
,
borderVal
),
(
float
)
readVal
<
T
>
(
src
,
iy
-
2
,
ix
,
c
,
border_type
,
borderVal
),
(
float
)
readVal
<
T
>
(
src
,
iy
-
2
,
ix
+
1
,
c
,
border_type
,
borderVal
)},
{(
float
)
readVal
<
T
>
(
src
,
iy
-
1
,
ix
-
2
,
c
,
border_type
,
borderVal
),
(
float
)
readVal
<
T
>
(
src
,
iy
-
1
,
ix
-
1
,
c
,
border_type
,
borderVal
),
(
float
)
readVal
<
T
>
(
src
,
iy
-
1
,
ix
,
c
,
border_type
,
borderVal
),
(
float
)
readVal
<
T
>
(
src
,
iy
-
1
,
ix
+
1
,
c
,
border_type
,
borderVal
)},
{(
float
)
readVal
<
T
>
(
src
,
iy
,
ix
-
2
,
c
,
border_type
,
borderVal
),
(
float
)
readVal
<
T
>
(
src
,
iy
,
ix
-
1
,
c
,
border_type
,
borderVal
),
(
float
)
readVal
<
T
>
(
src
,
iy
,
ix
,
c
,
border_type
,
borderVal
),
(
float
)
readVal
<
T
>
(
src
,
iy
,
ix
+
1
,
c
,
border_type
,
borderVal
)},
{(
float
)
readVal
<
T
>
(
src
,
iy
+
1
,
ix
-
2
,
c
,
border_type
,
borderVal
),
(
float
)
readVal
<
T
>
(
src
,
iy
+
1
,
ix
-
1
,
c
,
border_type
,
borderVal
),
(
float
)
readVal
<
T
>
(
src
,
iy
+
1
,
ix
,
c
,
border_type
,
borderVal
),
(
float
)
readVal
<
T
>
(
src
,
iy
+
1
,
ix
+
1
,
c
,
border_type
,
borderVal
)},
};
for
(
float
cx
=
xmin
;
cx
<=
xmax
;
cx
+=
1.0
f
)
{
const
float
w
=
bicubicCoeff
(
x
-
cx
)
*
bicubicCoeff
(
y
-
cy
);
sum
+=
w
*
readVal
<
T
>
(
src
,
cvFloor
(
cy
),
cvFloor
(
cx
),
c
,
border_type
,
borderVal
);
wsum
+=
w
;
}
}
return
cv
::
saturate_cast
<
T
>
(
getValue
(
vals
,
static_cast
<
float
>
((
x
-
ix
+
2.0
)
/
4.0
),
static_cast
<
float
>
((
y
-
iy
+
2.0
)
/
4.0
)));
float
res
=
(
!
wsum
)
?
0
:
sum
/
wsum
;
return
cv
::
saturate_cast
<
T
>
(
res
);
}
};
...
...
modules/gpu/test/test_remap.cpp
浏览文件 @
72d2311e
...
...
@@ -163,7 +163,7 @@ TEST_P(Remap, Accuracy)
cv
::
Mat
dst_gold
;
remapGold
(
src
,
xmap
,
ymap
,
dst_gold
,
interpolation
,
borderType
,
val
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
src
.
depth
()
==
CV_32F
?
1e-
4
:
1.0
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst
,
src
.
depth
()
==
CV_32F
?
1e-
3
:
1.0
);
}
INSTANTIATE_TEST_CASE_P
(
GPU_ImgProc
,
Remap
,
testing
::
Combine
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录