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
65ee06eb
Commit
65ee06eb
authored
Nov 27, 2013
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RGB[A] <-> XYZ
parent
506c1961
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
40 deletions
+63
-40
cvtcolor.cl
modules/imgproc/src/opencl/cvtcolor.cl
+63
-0
cvt_color.cl
modules/ocl/src/opencl/cvt_color.cl
+0
-40
No files found.
modules/imgproc/src/opencl/cvtcolor.cl
View file @
65ee06eb
...
...
@@ -345,7 +345,70 @@ __kernel void YCrCb2RGB(__global const uchar* src, int src_step, int src_offset,
}
}
/////////////////////////////////////
RGB
<->
XYZ
//////////////////////////////////////
__kernel
void
RGB2XYZ
(
int
cols,
int
rows,
int
src_step,
int
dst_step,
int
bidx,
__global
const
DATA_TYPE*
src,
__global
DATA_TYPE*
dst,
int
src_offset,
int
dst_offset,
__constant
COEFF_TYPE
*
coeffs
)
{
int
dx
=
get_global_id
(
0
)
;
int
dy
=
get_global_id
(
1
)
;
if
(
dy
<
rows
&&
dx
<
cols
)
{
dx
<<=
2
;
int
src_idx
=
mad24
(
dy,
src_step,
src_offset
+
dx
)
;
int
dst_idx
=
mad24
(
dy,
dst_step,
dst_offset
+
dx
)
;
DATA_TYPE
r
=
src[src_idx],
g
=
src[src_idx
+
1],
b
=
src[src_idx
+
2]
;
#
ifdef
DEPTH_5
float
x
=
r
*
coeffs[0]
+
g
*
coeffs[1]
+
b
*
coeffs[2]
;
float
y
=
r
*
coeffs[3]
+
g
*
coeffs[4]
+
b
*
coeffs[5]
;
float
z
=
r
*
coeffs[6]
+
g
*
coeffs[7]
+
b
*
coeffs[8]
;
#
else
int
x
=
CV_DESCALE
(
r
*
coeffs[0]
+
g
*
coeffs[1]
+
b
*
coeffs[2],
xyz_shift
)
;
int
y
=
CV_DESCALE
(
r
*
coeffs[3]
+
g
*
coeffs[4]
+
b
*
coeffs[5],
xyz_shift
)
;
int
z
=
CV_DESCALE
(
r
*
coeffs[6]
+
g
*
coeffs[7]
+
b
*
coeffs[8],
xyz_shift
)
;
#
endif
dst[dst_idx]
=
SAT_CAST
(
x
)
;
dst[dst_idx
+
1]
=
SAT_CAST
(
y
)
;
dst[dst_idx
+
2]
=
SAT_CAST
(
z
)
;
}
}
__kernel
void
XYZ2RGB
(
int
cols,
int
rows,
int
src_step,
int
dst_step,
int
bidx,
__global
const
DATA_TYPE*
src,
__global
DATA_TYPE*
dst,
int
src_offset,
int
dst_offset,
__constant
COEFF_TYPE
*
coeffs
)
{
int
dx
=
get_global_id
(
0
)
;
int
dy
=
get_global_id
(
1
)
;
if
(
dy
<
rows
&&
dx
<
cols
)
{
dx
<<=
2
;
int
src_idx
=
mad24
(
dy,
src_step,
src_offset
+
dx
)
;
int
dst_idx
=
mad24
(
dy,
dst_step,
dst_offset
+
dx
)
;
DATA_TYPE
x
=
src[src_idx],
y
=
src[src_idx
+
1],
z
=
src[src_idx
+
2]
;
#
ifdef
DEPTH_5
float
b
=
x
*
coeffs[0]
+
y
*
coeffs[1]
+
z
*
coeffs[2]
;
float
g
=
x
*
coeffs[3]
+
y
*
coeffs[4]
+
z
*
coeffs[5]
;
float
r
=
x
*
coeffs[6]
+
y
*
coeffs[7]
+
z
*
coeffs[8]
;
#
else
int
b
=
CV_DESCALE
(
x
*
coeffs[0]
+
y
*
coeffs[1]
+
z
*
coeffs[2],
xyz_shift
)
;
int
g
=
CV_DESCALE
(
x
*
coeffs[3]
+
y
*
coeffs[4]
+
z
*
coeffs[5],
xyz_shift
)
;
int
r
=
CV_DESCALE
(
x
*
coeffs[6]
+
y
*
coeffs[7]
+
z
*
coeffs[8],
xyz_shift
)
;
#
endif
dst[dst_idx]
=
SAT_CAST
(
b
)
;
dst[dst_idx
+
1]
=
SAT_CAST
(
g
)
;
dst[dst_idx
+
2]
=
SAT_CAST
(
r
)
;
#
if
dcn
==
4
dst[dst_idx
+
3]
=
MAX_NUM
;
#
endif
}
}
...
...
modules/ocl/src/opencl/cvt_color.cl
View file @
65ee06eb
...
...
@@ -91,46 +91,6 @@ enum
BLOCK_SIZE
=
256
}
;
__constant
float
c_YCrCb2RGBCoeffs_f[4]
=
{
1.403f,
-0.714f,
-0.344f,
1.773f
}
;
__constant
int
c_YCrCb2RGBCoeffs_i[4]
=
{
22987
,
-11698
,
-5636
,
29049
}
;
__kernel
void
YCrCb2RGB
(
int
cols,
int
rows,
int
src_step,
int
dst_step,
int
bidx,
__global
const
DATA_TYPE*
src,
__global
DATA_TYPE*
dst,
int
src_offset,
int
dst_offset
)
{
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
)
;
DATA_TYPE
ycrcb[]
=
{
src[src_idx],
src[src_idx
+
1],
src[src_idx
+
2]
}
;
#
ifdef
DEPTH_5
__constant
float
*
coeff
=
c_YCrCb2RGBCoeffs_f
;
float
r
=
ycrcb[0]
+
coeff[0]
*
(
ycrcb[1]
-
HALF_MAX
)
;
float
g
=
ycrcb[0]
+
coeff[1]
*
(
ycrcb[1]
-
HALF_MAX
)
+
coeff[2]
*
(
ycrcb[2]
-
HALF_MAX
)
;
float
b
=
ycrcb[0]
+
coeff[3]
*
(
ycrcb[2]
-
HALF_MAX
)
;
#
else
__constant
int
*
coeff
=
c_YCrCb2RGBCoeffs_i
;
int
r
=
ycrcb[0]
+
CV_DESCALE
(
coeff[0]
*
(
ycrcb[1]
-
HALF_MAX
)
,
yuv_shift
)
;
int
g
=
ycrcb[0]
+
CV_DESCALE
(
coeff[1]
*
(
ycrcb[1]
-
HALF_MAX
)
+
coeff[2]
*
(
ycrcb[2]
-
HALF_MAX
)
,
yuv_shift
)
;
int
b
=
ycrcb[0]
+
CV_DESCALE
(
coeff[3]
*
(
ycrcb[2]
-
HALF_MAX
)
,
yuv_shift
)
;
#
endif
dst[dst_idx
+
(
bidx^2
)
]
=
SAT_CAST
(
r
)
;
dst[dst_idx
+
1]
=
SAT_CAST
(
g
)
;
dst[dst_idx
+
bidx]
=
SAT_CAST
(
b
)
;
#
if
dcn
==
4
dst[dst_idx
+
3]
=
MAX_NUM
;
#
endif
}
}
/////////////////////////////////////
RGB
<->
XYZ
//////////////////////////////////////
__kernel
void
RGB2XYZ
(
int
cols,
int
rows,
int
src_step,
int
dst_step,
...
...
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