Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
6f05a250
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,发现更多精彩内容 >>
提交
6f05a250
编写于
9月 30, 2014
作者:
I
Ilya Lavrenov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimization of cv::CLAHE (~3x)
上级
af6a64d7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
24 deletion
+41
-24
modules/imgproc/src/clahe.cpp
modules/imgproc/src/clahe.cpp
+41
-24
未找到文件。
modules/imgproc/src/clahe.cpp
浏览文件 @
6f05a250
...
...
@@ -233,6 +233,31 @@ namespace
CLAHE_Interpolation_Body
(
const
cv
::
Mat
&
src
,
const
cv
::
Mat
&
dst
,
const
cv
::
Mat
&
lut
,
const
cv
::
Size
&
tileSize
,
const
int
&
tilesX
,
const
int
&
tilesY
)
:
src_
(
src
),
dst_
(
dst
),
lut_
(
lut
),
tileSize_
(
tileSize
),
tilesX_
(
tilesX
),
tilesY_
(
tilesY
)
{
buf
.
allocate
(
src
.
cols
<<
2
);
ind1_p
=
(
int
*
)
buf
;
ind2_p
=
ind1_p
+
src
.
cols
;
xa_p
=
(
float
*
)(
ind2_p
+
src
.
cols
);
xa1_p
=
xa_p
+
src
.
cols
;
int
lut_step
=
static_cast
<
int
>
(
lut_
.
step
/
sizeof
(
T
));
float
inv_tw
=
1.0
f
/
tileSize_
.
width
;
for
(
int
x
=
0
;
x
<
src
.
cols
;
++
x
)
{
float
txf
=
x
*
inv_tw
-
0.5
f
;
int
tx1
=
cvFloor
(
txf
);
int
tx2
=
tx1
+
1
;
xa_p
[
x
]
=
txf
-
tx1
;
xa1_p
[
x
]
=
1.0
f
-
xa_p
[
x
];
tx1
=
std
::
max
(
tx1
,
0
);
tx2
=
std
::
min
(
tx2
,
tilesX_
-
1
);
ind1_p
[
x
]
=
tx1
*
lut_step
;
ind2_p
[
x
]
=
tx2
*
lut_step
;
}
}
void
operator
()(
const
cv
::
Range
&
range
)
const
;
...
...
@@ -245,24 +270,28 @@ namespace
cv
::
Size
tileSize_
;
int
tilesX_
;
int
tilesY_
;
cv
::
AutoBuffer
<
int
>
buf
;
int
*
ind1_p
,
*
ind2_p
;
float
*
xa_p
,
*
xa1_p
;
};
template
<
class
T
>
void
CLAHE_Interpolation_Body
<
T
>::
operator
()(
const
cv
::
Range
&
range
)
const
{
const
size_t
lut_step
=
lut_
.
step
/
sizeof
(
T
)
;
float
inv_th
=
1.0
f
/
tileSize_
.
height
;
for
(
int
y
=
range
.
start
;
y
<
range
.
end
;
++
y
)
{
const
T
*
srcRow
=
src_
.
ptr
<
T
>
(
y
);
T
*
dstRow
=
dst_
.
ptr
<
T
>
(
y
);
const
float
tyf
=
(
static_cast
<
float
>
(
y
)
/
tileSize_
.
height
)
-
0.5
f
;
float
tyf
=
y
*
inv_th
-
0.5
f
;
int
ty1
=
cvFloor
(
tyf
);
int
ty2
=
ty1
+
1
;
const
float
ya
=
tyf
-
ty1
;
float
ya
=
tyf
-
ty1
,
ya1
=
1.0
f
-
ya
;
ty1
=
std
::
max
(
ty1
,
0
);
ty2
=
std
::
min
(
ty2
,
tilesY_
-
1
);
...
...
@@ -272,27 +301,13 @@ namespace
for
(
int
x
=
0
;
x
<
src_
.
cols
;
++
x
)
{
const
float
txf
=
(
static_cast
<
float
>
(
x
)
/
tileSize_
.
width
)
-
0.5
f
;
int
tx1
=
cvFloor
(
txf
);
int
tx2
=
tx1
+
1
;
int
srcVal
=
srcRow
[
x
];
const
float
xa
=
txf
-
tx1
;
tx1
=
std
::
max
(
tx1
,
0
);
tx2
=
std
::
min
(
tx2
,
tilesX_
-
1
);
int
ind1
=
ind1_p
[
x
]
+
srcVal
;
int
ind2
=
ind2_p
[
x
]
+
srcVal
;
const
int
srcVal
=
srcRow
[
x
];
const
size_t
ind1
=
tx1
*
lut_step
+
srcVal
;
const
size_t
ind2
=
tx2
*
lut_step
+
srcVal
;
float
res
=
0
;
res
+=
lutPlane1
[
ind1
]
*
((
1.0
f
-
xa
)
*
(
1.0
f
-
ya
));
res
+=
lutPlane1
[
ind2
]
*
((
xa
)
*
(
1.0
f
-
ya
));
res
+=
lutPlane2
[
ind1
]
*
((
1.0
f
-
xa
)
*
(
ya
));
res
+=
lutPlane2
[
ind2
]
*
((
xa
)
*
(
ya
));
float
res
=
(
lutPlane1
[
ind1
]
*
xa1_p
[
x
]
+
lutPlane1
[
ind2
]
*
xa_p
[
x
])
*
ya1
+
(
lutPlane2
[
ind1
]
*
xa1_p
[
x
]
+
lutPlane2
[
ind2
]
*
xa_p
[
x
])
*
ya
;
dstRow
[
x
]
=
cv
::
saturate_cast
<
T
>
(
res
);
}
...
...
@@ -403,7 +418,9 @@ namespace
calcLutBody
=
cv
::
makePtr
<
CLAHE_CalcLut_Body
<
uchar
,
256
,
0
>
>
(
srcForLut
,
lut_
,
tileSize
,
tilesX_
,
clipLimit
,
lutScale
);
else
if
(
_src
.
type
()
==
CV_16UC1
)
calcLutBody
=
cv
::
makePtr
<
CLAHE_CalcLut_Body
<
ushort
,
4096
,
4
>
>
(
srcForLut
,
lut_
,
tileSize
,
tilesX_
,
clipLimit
,
lutScale
);
CV_Assert
(
!
calcLutBody
.
empty
());
else
CV_Error
(
CV_StsBadArg
,
"Unsupported type"
);
cv
::
parallel_for_
(
cv
::
Range
(
0
,
tilesX_
*
tilesY_
),
*
calcLutBody
);
cv
::
Ptr
<
cv
::
ParallelLoopBody
>
interpolationBody
;
...
...
@@ -411,7 +428,7 @@ namespace
interpolationBody
=
cv
::
makePtr
<
CLAHE_Interpolation_Body
<
uchar
>
>
(
src
,
dst
,
lut_
,
tileSize
,
tilesX_
,
tilesY_
);
else
if
(
_src
.
type
()
==
CV_16UC1
)
interpolationBody
=
cv
::
makePtr
<
CLAHE_Interpolation_Body
<
ushort
>
>
(
src
,
dst
,
lut_
,
tileSize
,
tilesX_
,
tilesY_
);
CV_Assert
(
!
interpolationBody
.
empty
());
cv
::
parallel_for_
(
cv
::
Range
(
0
,
src
.
rows
),
*
interpolationBody
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录