Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
058367f3
Commit
058367f3
authored
Jun 07, 2019
by
Chip Kerchner Chip.Kerchner@ibm.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite code in BGR2Gray functions so that auto vectorizer does a better job.
parent
0d477d73
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
utils.cpp
modules/imgcodecs/src/utils.cpp
+12
-6
No files found.
modules/imgcodecs/src/utils.cpp
View file @
058367f3
...
...
@@ -61,12 +61,14 @@ void icvCvt_BGR2Gray_8u_C3C1R( const uchar* rgb, int rgb_step,
Size
size
,
int
_swap_rb
)
{
int
i
;
int
swap_rb
=
_swap_rb
?
2
:
0
;
for
(
;
size
.
height
--
;
gray
+=
gray_step
)
{
short
cRGB0
=
cR
;
short
cRGB2
=
cB
;
if
(
_swap_rb
)
std
::
swap
(
cRGB0
,
cRGB2
);
for
(
i
=
0
;
i
<
size
.
width
;
i
++
,
rgb
+=
3
)
{
int
t
=
descale
(
rgb
[
swap_rb
]
*
cB
+
rgb
[
1
]
*
cG
+
rgb
[
swap_rb
^
2
]
*
cR
,
SCALE
);
int
t
=
descale
(
rgb
[
0
]
*
cRGB0
+
rgb
[
1
]
*
cG
+
rgb
[
2
]
*
cRGB2
,
SCALE
);
gray
[
i
]
=
(
uchar
)
t
;
}
...
...
@@ -80,12 +82,14 @@ void icvCvt_BGRA2Gray_16u_CnC1R( const ushort* rgb, int rgb_step,
Size
size
,
int
ncn
,
int
_swap_rb
)
{
int
i
;
int
swap_rb
=
_swap_rb
?
2
:
0
;
for
(
;
size
.
height
--
;
gray
+=
gray_step
)
{
short
cRGB0
=
cR
;
short
cRGB2
=
cB
;
if
(
_swap_rb
)
std
::
swap
(
cRGB0
,
cRGB2
);
for
(
i
=
0
;
i
<
size
.
width
;
i
++
,
rgb
+=
ncn
)
{
int
t
=
descale
(
rgb
[
swap_rb
]
*
cB
+
rgb
[
1
]
*
cG
+
rgb
[
swap_rb
^
2
]
*
cR
,
SCALE
);
int
t
=
descale
(
rgb
[
0
]
*
cRGB0
+
rgb
[
1
]
*
cG
+
rgb
[
2
]
*
cRGB2
,
SCALE
);
gray
[
i
]
=
(
ushort
)
t
;
}
...
...
@@ -99,12 +103,14 @@ void icvCvt_BGRA2Gray_8u_C4C1R( const uchar* rgba, int rgba_step,
Size
size
,
int
_swap_rb
)
{
int
i
;
int
swap_rb
=
_swap_rb
?
2
:
0
;
for
(
;
size
.
height
--
;
gray
+=
gray_step
)
{
short
cRGB0
=
cR
;
short
cRGB2
=
cB
;
if
(
_swap_rb
)
std
::
swap
(
cRGB0
,
cRGB2
);
for
(
i
=
0
;
i
<
size
.
width
;
i
++
,
rgba
+=
4
)
{
int
t
=
descale
(
rgba
[
swap_rb
]
*
cB
+
rgba
[
1
]
*
cG
+
rgba
[
swap_rb
^
2
]
*
cR
,
SCALE
);
int
t
=
descale
(
rgba
[
0
]
*
cRGB0
+
rgba
[
1
]
*
cG
+
rgba
[
2
]
*
cRGB2
,
SCALE
);
gray
[
i
]
=
(
uchar
)
t
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment