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
74bc8d35
Commit
74bc8d35
authored
Jan 05, 2020
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16265 from JanuszL:fix_bgr
parents
40ac72a8
178c4810
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
21 deletions
+21
-21
utils.cpp
modules/imgcodecs/src/utils.cpp
+21
-21
No files found.
modules/imgcodecs/src/utils.cpp
View file @
74bc8d35
...
...
@@ -56,65 +56,65 @@ int validateToInt(size_t sz)
#define cG (int)(0.587*(1 << SCALE) + 0.5)
#define cB ((1 << SCALE) - cR - cG)
void
icvCvt_BGR2Gray_8u_C3C1R
(
const
uchar
*
rgb
,
int
rgb
_step
,
void
icvCvt_BGR2Gray_8u_C3C1R
(
const
uchar
*
bgr
,
int
bgr
_step
,
uchar
*
gray
,
int
gray_step
,
Size
size
,
int
_swap_rb
)
{
int
i
;
for
(
;
size
.
height
--
;
gray
+=
gray_step
)
{
short
c
RGB0
=
cR
;
short
c
RGB2
=
cB
;
if
(
_swap_rb
)
std
::
swap
(
c
RGB0
,
cRGB
2
);
for
(
i
=
0
;
i
<
size
.
width
;
i
++
,
rgb
+=
3
)
short
c
BGR0
=
cB
;
short
c
BGR2
=
cR
;
if
(
_swap_rb
)
std
::
swap
(
c
BGR0
,
cBGR
2
);
for
(
i
=
0
;
i
<
size
.
width
;
i
++
,
bgr
+=
3
)
{
int
t
=
descale
(
rgb
[
0
]
*
cRGB0
+
rgb
[
1
]
*
cG
+
rgb
[
2
]
*
cRGB
2
,
SCALE
);
int
t
=
descale
(
bgr
[
0
]
*
cBGR0
+
bgr
[
1
]
*
cG
+
bgr
[
2
]
*
cBGR
2
,
SCALE
);
gray
[
i
]
=
(
uchar
)
t
;
}
rgb
+=
rgb
_step
-
size
.
width
*
3
;
bgr
+=
bgr
_step
-
size
.
width
*
3
;
}
}
void
icvCvt_BGRA2Gray_16u_CnC1R
(
const
ushort
*
rgb
,
int
rgb
_step
,
void
icvCvt_BGRA2Gray_16u_CnC1R
(
const
ushort
*
bgr
,
int
bgr
_step
,
ushort
*
gray
,
int
gray_step
,
Size
size
,
int
ncn
,
int
_swap_rb
)
{
int
i
;
for
(
;
size
.
height
--
;
gray
+=
gray_step
)
{
short
c
RGB0
=
cR
;
short
c
RGB2
=
cB
;
if
(
_swap_rb
)
std
::
swap
(
c
RGB0
,
cRGB
2
);
for
(
i
=
0
;
i
<
size
.
width
;
i
++
,
rgb
+=
ncn
)
short
c
BGR0
=
cB
;
short
c
BGR2
=
cR
;
if
(
_swap_rb
)
std
::
swap
(
c
BGR0
,
cBGR
2
);
for
(
i
=
0
;
i
<
size
.
width
;
i
++
,
bgr
+=
ncn
)
{
int
t
=
descale
(
rgb
[
0
]
*
cRGB0
+
rgb
[
1
]
*
cG
+
rgb
[
2
]
*
cRGB
2
,
SCALE
);
int
t
=
descale
(
bgr
[
0
]
*
cBGR0
+
bgr
[
1
]
*
cG
+
bgr
[
2
]
*
cBGR
2
,
SCALE
);
gray
[
i
]
=
(
ushort
)
t
;
}
rgb
+=
rgb
_step
-
size
.
width
*
ncn
;
bgr
+=
bgr
_step
-
size
.
width
*
ncn
;
}
}
void
icvCvt_BGRA2Gray_8u_C4C1R
(
const
uchar
*
rgb
a
,
int
rgba_step
,
void
icvCvt_BGRA2Gray_8u_C4C1R
(
const
uchar
*
bgr
a
,
int
rgba_step
,
uchar
*
gray
,
int
gray_step
,
Size
size
,
int
_swap_rb
)
{
int
i
;
for
(
;
size
.
height
--
;
gray
+=
gray_step
)
{
short
c
RGB0
=
cR
;
short
c
RGB2
=
cB
;
if
(
_swap_rb
)
std
::
swap
(
c
RGB0
,
cRGB
2
);
for
(
i
=
0
;
i
<
size
.
width
;
i
++
,
rgb
a
+=
4
)
short
c
BGR0
=
cB
;
short
c
BGR2
=
cR
;
if
(
_swap_rb
)
std
::
swap
(
c
BGR0
,
cBGR
2
);
for
(
i
=
0
;
i
<
size
.
width
;
i
++
,
bgr
a
+=
4
)
{
int
t
=
descale
(
rgba
[
0
]
*
cRGB0
+
rgba
[
1
]
*
cG
+
rgba
[
2
]
*
cRGB
2
,
SCALE
);
int
t
=
descale
(
bgra
[
0
]
*
cBGR0
+
bgra
[
1
]
*
cG
+
bgra
[
2
]
*
cBGR
2
,
SCALE
);
gray
[
i
]
=
(
uchar
)
t
;
}
rgb
a
+=
rgba_step
-
size
.
width
*
4
;
bgr
a
+=
rgba_step
-
size
.
width
*
4
;
}
}
...
...
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