Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
a1b3ba02
O
Opencv
项目概览
Greenplum
/
Opencv
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
a1b3ba02
编写于
7月 01, 2013
作者:
S
siddharth
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add color_boost + doc
上级
88aa4a99
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
75 addition
and
12 deletion
+75
-12
modules/photo/doc/decolor.rst
modules/photo/doc/decolor.rst
+20
-0
modules/photo/include/opencv2/photo.hpp
modules/photo/include/opencv2/photo.hpp
+1
-1
modules/photo/src/contrast_preserve.cpp
modules/photo/src/contrast_preserve.cpp
+42
-4
modules/photo/test/test_decolor.cpp
modules/photo/test/test_decolor.cpp
+12
-7
未找到文件。
modules/photo/doc/decolor.rst
0 → 100644
浏览文件 @
a1b3ba02
Decolorization
==============
.. highlight:: cpp
decolor
-------
Transforms a color image to a grayscale image. It is a basic tool in digital printing, stylized black-and-white photograph rendering, and in many single channel image processing applications.
.. ocv:function:: void decolor( InputArray src, OutputArray grayscale, OutputArray color_boost )
:param src: Input 8-bit 3-channel image.
:param grayscale: Output 8-bit 1-channel image.
:param color_boost: Output 8-bit 3-channel image.
This function is to be applied on color images.
modules/photo/include/opencv2/photo.hpp
浏览文件 @
a1b3ba02
...
...
@@ -288,7 +288,7 @@ public:
CV_EXPORTS_W
Ptr
<
MergeRobertson
>
createMergeRobertson
();
CV_EXPORTS_W
void
decolor
(
InputArray
src
,
OutputArray
grayscale
);
CV_EXPORTS_W
void
decolor
(
InputArray
src
,
OutputArray
grayscale
,
OutputArray
color_boost
);
}
// cv
...
...
modules/photo/src/contrast_preserve.cpp
浏览文件 @
a1b3ba02
...
...
@@ -17,14 +17,17 @@ int rounding(double a)
return
int
(
a
+
0.5
);
}
void
cv
::
decolor
(
InputArray
_src
,
OutputArray
_dst
)
void
cv
::
decolor
(
InputArray
_src
,
OutputArray
_dst
,
OutputArray
_boost
)
{
Mat
I
=
_src
.
getMat
();
Mat
I
=
_src
.
getMat
();
_dst
.
create
(
I
.
size
(),
CV_8UC1
);
Mat
dst
=
_dst
.
getMat
();
if
(
!
I
.
data
)
{
_boost
.
create
(
I
.
size
(),
CV_8UC3
);
Mat
color_boost
=
_boost
.
getMat
();
if
(
!
I
.
data
)
{
cout
<<
"Could not open or find the image"
<<
endl
;
return
;
}
...
...
@@ -162,5 +165,40 @@ void cv::decolor(InputArray _src, OutputArray _dst)
Gray
.
convertTo
(
dst
,
CV_8UC1
,
255
);
/////////////////////////////////// Contrast Boosting /////////////////////////////////
Mat
lab
=
Mat
(
img
.
size
(),
CV_8UC3
);
Mat
color
=
Mat
(
img
.
size
(),
CV_8UC3
);
Mat
l
=
Mat
(
img
.
size
(),
CV_8UC1
);
Mat
a
=
Mat
(
img
.
size
(),
CV_8UC1
);
Mat
b
=
Mat
(
img
.
size
(),
CV_8UC1
);
cvtColor
(
I
,
lab
,
COLOR_BGR2Lab
);
int
h1
=
img
.
size
().
height
;
int
w1
=
img
.
size
().
width
;
for
(
int
i
=
0
;
i
<
h1
;
i
++
)
for
(
int
j
=
0
;
j
<
w1
;
j
++
)
{
l
.
at
<
uchar
>
(
i
,
j
)
=
lab
.
at
<
uchar
>
(
i
,
j
*
3
+
0
);
a
.
at
<
uchar
>
(
i
,
j
)
=
lab
.
at
<
uchar
>
(
i
,
j
*
3
+
1
);
b
.
at
<
uchar
>
(
i
,
j
)
=
lab
.
at
<
uchar
>
(
i
,
j
*
3
+
2
);
}
for
(
int
i
=
0
;
i
<
h1
;
i
++
)
for
(
int
j
=
0
;
j
<
w1
;
j
++
)
{
l
.
at
<
uchar
>
(
i
,
j
)
=
255.0
*
Gray
.
at
<
float
>
(
i
,
j
);
}
for
(
int
i
=
0
;
i
<
h1
;
i
++
)
for
(
int
j
=
0
;
j
<
w1
;
j
++
)
{
lab
.
at
<
uchar
>
(
i
,
j
*
3
+
0
)
=
l
.
at
<
uchar
>
(
i
,
j
);
lab
.
at
<
uchar
>
(
i
,
j
*
3
+
1
)
=
a
.
at
<
uchar
>
(
i
,
j
);
lab
.
at
<
uchar
>
(
i
,
j
*
3
+
2
)
=
b
.
at
<
uchar
>
(
i
,
j
);
}
cvtColor
(
lab
,
color_boost
,
COLOR_Lab2BGR
);
}
modules/photo/test/test_decolor.cpp
浏览文件 @
a1b3ba02
...
...
@@ -16,19 +16,24 @@ TEST(Photo_Decolor, regression)
{
string
folder
=
string
(
cvtest
::
TS
::
ptr
()
->
get_data_path
())
+
"decolor/"
;
string
original_path
=
folder
+
"color_image_1.png"
;
string
expected_path
=
folder
+
"grayscale_image_1.png"
;
string
expected_path1
=
folder
+
"grayscale_image_1.png"
;
string
expected_path2
=
folder
+
"color_boost_image_1.png"
;
Mat
original
=
imread
(
original_path
,
IMREAD_COLOR
);
Mat
expected
=
imread
(
expected_path
,
IMREAD_GRAYSCALE
);
Mat
expected1
=
imread
(
expected_path1
,
IMREAD_GRAYSCALE
);
Mat
expected2
=
imread
(
expected_path2
,
IMREAD_COLOR
);
ASSERT_FALSE
(
original
.
empty
())
<<
"Could not load input image "
<<
original_path
;
ASSERT_FALSE
(
expected
.
empty
())
<<
"Could not load reference image "
<<
expected_path
;
ASSERT_FALSE
(
expected1
.
empty
())
<<
"Could not load reference image "
<<
expected_path1
;
ASSERT_FALSE
(
expected2
.
empty
())
<<
"Could not load reference image "
<<
expected_path2
;
Mat
resul
t
;
decolor
(
original
,
resul
t
);
Mat
grayscale
,
color_boos
t
;
decolor
(
original
,
grayscale
,
color_boos
t
);
DUMP
(
result
,
expected_path
+
".res.png"
);
DUMP
(
grayscale
,
expected_path1
+
".grayscale.png"
);
DUMP
(
color_boost
,
expected_path2
+
".color_boost.png"
);
ASSERT_EQ
(
0
,
norm
(
result
!=
expected
));
ASSERT_EQ
(
0
,
norm
(
grayscale
!=
expected1
));
ASSERT_EQ
(
0
,
norm
(
color_boost
!=
expected2
));
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录