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
d2e13183
Commit
d2e13183
authored
Nov 27, 2013
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RGBA <-> mRGBA
parent
f771a0ba
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
2 deletions
+54
-2
color.cpp
modules/imgproc/src/color.cpp
+9
-0
cvtcolor.cl
modules/imgproc/src/opencl/cvtcolor.cl
+43
-0
test_color.cpp
modules/imgproc/test/ocl/test_color.cpp
+2
-2
No files found.
modules/imgproc/src/color.cpp
View file @
d2e13183
...
@@ -3010,6 +3010,15 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
...
@@ -3010,6 +3010,15 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
depth
,
dcn
,
bidx
,
hrange
,
6.
f
/
hrange
));
depth
,
dcn
,
bidx
,
hrange
,
6.
f
/
hrange
));
break
;
break
;
}
}
case
COLOR_RGBA2mRGBA
:
case
COLOR_mRGBA2RGBA
:
{
CV_Assert
(
scn
==
4
&&
depth
==
CV_8U
);
dcn
=
4
;
k
.
create
(
code
==
COLOR_RGBA2mRGBA
?
"RGBA2mRGBA"
:
"mRGBA2RGBA"
,
ocl
::
imgproc
::
cvtcolor_oclsrc
,
format
(
"-D depth=%d -D dcn=4 -D scn=4 -D bidx=3"
,
depth
));
break
;
}
default:
default:
;
;
}
}
...
...
modules/imgproc/src/opencl/cvtcolor.cl
View file @
d2e13183
...
@@ -988,12 +988,55 @@ __kernel void HLS2RGB(__global const uchar* srcptr, int src_step, int src_offset
...
@@ -988,12 +988,55 @@ __kernel void HLS2RGB(__global const uchar* srcptr, int src_step, int src_offset
#
endif
#
endif
///////////////////////////
RGBA
<->
mRGBA
(
alpha
premultiplied
)
//////////////
#
ifdef
DEPTH_0
__kernel
void
RGBA2mRGBA
(
__global
const
uchar*
src,
int
src_step,
int
src_offset,
__global
uchar*
dst,
int
dst_step,
int
dst_offset,
int
rows,
int
cols
)
{
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
if
(
y
<
rows
&&
x
<
cols
)
{
x
<<=
2
;
int
src_idx
=
mad24
(
y,
src_step,
src_offset
+
x
)
;
int
dst_idx
=
mad24
(
y,
dst_step,
dst_offset
+
x
)
;
uchar
v0
=
src[src_idx],
v1
=
src[src_idx
+
1]
;
uchar
v2
=
src[src_idx
+
2],
v3
=
src[src_idx
+
3]
;
dst[dst_idx]
=
(
v0
*
v3
+
HALF_MAX
)
/
MAX_NUM
;
dst[dst_idx
+
1]
=
(
v1
*
v3
+
HALF_MAX
)
/
MAX_NUM
;
dst[dst_idx
+
2]
=
(
v2
*
v3
+
HALF_MAX
)
/
MAX_NUM
;
dst[dst_idx
+
3]
=
v3
;
}
}
__kernel
void
mRGBA2RGBA
(
__global
const
uchar*
src,
int
src_step,
int
src_offset,
__global
uchar*
dst,
int
dst_step,
int
dst_offset,
int
rows,
int
cols
)
{
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
if
(
y
<
rows
&&
x
<
cols
)
{
x
<<=
2
;
int
src_idx
=
mad24
(
y,
src_step,
src_offset
+
x
)
;
int
dst_idx
=
mad24
(
y,
dst_step,
dst_offset
+
x
)
;
uchar
v0
=
src[src_idx],
v1
=
src[src_idx
+
1]
;
uchar
v2
=
src[src_idx
+
2],
v3
=
src[src_idx
+
3]
;
uchar
v3_half
=
v3
/
2
;
dst[dst_idx]
=
v3
==
0
?
0
:
(
v0
*
MAX_NUM
+
v3_half
)
/
v3
;
dst[dst_idx
+
1]
=
v3
==
0
?
0
:
(
v1
*
MAX_NUM
+
v3_half
)
/
v3
;
dst[dst_idx
+
2]
=
v3
==
0
?
0
:
(
v2
*
MAX_NUM
+
v3_half
)
/
v3
;
dst[dst_idx
+
3]
=
v3
;
}
}
#
endif
modules/imgproc/test/ocl/test_color.cpp
View file @
d2e13183
...
@@ -247,8 +247,8 @@ OCL_TEST_P(CvtColor8u, GRAY2BGR555) { performTest(1, 2, CVTCODE(GRAY2BGR555)); }
...
@@ -247,8 +247,8 @@ OCL_TEST_P(CvtColor8u, GRAY2BGR555) { performTest(1, 2, CVTCODE(GRAY2BGR555)); }
// RGBA <-> mRGBA
// RGBA <-> mRGBA
//
OCL_TEST_P(CvtColor8u, RGBA2mRGBA) { performTest(4, 4, CVTCODE(RGBA2mRGBA)); }
OCL_TEST_P
(
CvtColor8u
,
RGBA2mRGBA
)
{
performTest
(
4
,
4
,
CVTCODE
(
RGBA2mRGBA
));
}
//
OCL_TEST_P(CvtColor8u, mRGBA2RGBA) { performTest(4, 4, CVTCODE(mRGBA2RGBA)); }
OCL_TEST_P
(
CvtColor8u
,
mRGBA2RGBA
)
{
performTest
(
4
,
4
,
CVTCODE
(
mRGBA2RGBA
));
}
// YUV -> RGBA_NV12
// YUV -> RGBA_NV12
...
...
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