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
aaf56c28
Commit
aaf56c28
authored
May 27, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14649 from savuor:fix/luv_hls_read_oob
parents
05563f5b
8c698262
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
13 deletions
+38
-13
color_hsv.simd.hpp
modules/imgproc/src/color_hsv.simd.hpp
+18
-6
color_lab.cpp
modules/imgproc/src/color_lab.cpp
+20
-7
No files found.
modules/imgproc/src/color_hsv.simd.hpp
View file @
aaf56c28
...
@@ -724,7 +724,7 @@ struct RGB2HLS_b
...
@@ -724,7 +724,7 @@ struct RGB2HLS_b
{
{
CV_INSTRUMENT_REGION
();
CV_INSTRUMENT_REGION
();
int
i
,
j
,
scn
=
srccn
;
int
scn
=
srccn
;
#if CV_SIMD
#if CV_SIMD
float
CV_DECL_ALIGNED
(
CV_SIMD_WIDTH
)
buf
[
bufChannels
*
BLOCK_SIZE
];
float
CV_DECL_ALIGNED
(
CV_SIMD_WIDTH
)
buf
[
bufChannels
*
BLOCK_SIZE
];
...
@@ -744,15 +744,15 @@ struct RGB2HLS_b
...
@@ -744,15 +744,15 @@ struct RGB2HLS_b
}
}
#endif
#endif
for
(
i
=
0
;
i
<
n
;
i
+=
BLOCK_SIZE
,
dst
+=
BLOCK_SIZE
*
3
)
for
(
int
i
=
0
;
i
<
n
;
i
+=
BLOCK_SIZE
,
dst
+=
BLOCK_SIZE
*
3
)
{
{
int
dn
=
std
::
min
(
n
-
i
,
(
int
)
BLOCK_SIZE
);
int
dn
=
std
::
min
(
n
-
i
,
(
int
)
BLOCK_SIZE
);
j
=
0
;
#if CV_SIMD
#if CV_SIMD
v_float32
v255inv
=
vx_setall_f32
(
1.
f
/
255.
f
);
v_float32
v255inv
=
vx_setall_f32
(
1.
f
/
255.
f
);
if
(
scn
==
3
)
if
(
scn
==
3
)
{
{
int
j
=
0
;
static
const
int
nBlock
=
fsize
*
2
;
static
const
int
nBlock
=
fsize
*
2
;
for
(
;
j
<=
(
dn
*
bufChannels
-
nBlock
);
for
(
;
j
<=
(
dn
*
bufChannels
-
nBlock
);
j
+=
nBlock
,
src
+=
nBlock
)
j
+=
nBlock
,
src
+=
nBlock
)
...
@@ -763,9 +763,14 @@ struct RGB2HLS_b
...
@@ -763,9 +763,14 @@ struct RGB2HLS_b
v_store_aligned
(
buf
+
j
+
0
*
fsize
,
v_cvt_f32
(
qrgb0
)
*
v255inv
);
v_store_aligned
(
buf
+
j
+
0
*
fsize
,
v_cvt_f32
(
qrgb0
)
*
v255inv
);
v_store_aligned
(
buf
+
j
+
1
*
fsize
,
v_cvt_f32
(
qrgb1
)
*
v255inv
);
v_store_aligned
(
buf
+
j
+
1
*
fsize
,
v_cvt_f32
(
qrgb1
)
*
v255inv
);
}
}
for
(
;
j
<
dn
*
3
;
j
++
,
src
++
)
{
buf
[
j
]
=
src
[
0
]
*
(
1.
f
/
255.
f
);
}
}
}
else
// if (scn == 4)
else
// if (scn == 4)
{
{
int
j
=
0
;
static
const
int
nBlock
=
fsize
*
4
;
static
const
int
nBlock
=
fsize
*
4
;
for
(
;
j
<=
dn
*
bufChannels
-
nBlock
*
bufChannels
;
for
(
;
j
<=
dn
*
bufChannels
-
nBlock
*
bufChannels
;
j
+=
nBlock
*
bufChannels
,
src
+=
nBlock
*
4
)
j
+=
nBlock
*
bufChannels
,
src
+=
nBlock
*
4
)
...
@@ -795,17 +800,24 @@ struct RGB2HLS_b
...
@@ -795,17 +800,24 @@ struct RGB2HLS_b
v_store_interleave
(
buf
+
j
+
k
*
bufChannels
*
fsize
,
f
[
0
*
4
+
k
],
f
[
1
*
4
+
k
],
f
[
2
*
4
+
k
]);
v_store_interleave
(
buf
+
j
+
k
*
bufChannels
*
fsize
,
f
[
0
*
4
+
k
],
f
[
1
*
4
+
k
],
f
[
2
*
4
+
k
]);
}
}
}
}
for
(
;
j
<
dn
*
3
;
j
+=
3
,
src
+=
4
)
{
buf
[
j
+
0
]
=
src
[
0
]
*
(
1.
f
/
255.
f
);
buf
[
j
+
1
]
=
src
[
1
]
*
(
1.
f
/
255.
f
);
buf
[
j
+
2
]
=
src
[
2
]
*
(
1.
f
/
255.
f
);
}
}
}
#e
ndif
#e
lse
for
(
;
j
<
dn
*
3
;
j
+=
3
,
src
+=
scn
)
for
(
int
j
=
0
;
j
<
dn
*
3
;
j
+=
3
,
src
+=
scn
)
{
{
buf
[
j
+
0
]
=
src
[
0
]
*
(
1.
f
/
255.
f
);
buf
[
j
+
0
]
=
src
[
0
]
*
(
1.
f
/
255.
f
);
buf
[
j
+
1
]
=
src
[
1
]
*
(
1.
f
/
255.
f
);
buf
[
j
+
1
]
=
src
[
1
]
*
(
1.
f
/
255.
f
);
buf
[
j
+
2
]
=
src
[
2
]
*
(
1.
f
/
255.
f
);
buf
[
j
+
2
]
=
src
[
2
]
*
(
1.
f
/
255.
f
);
}
}
#endif
cvt
(
buf
,
buf
,
dn
);
cvt
(
buf
,
buf
,
dn
);
j
=
0
;
int
j
=
0
;
#if CV_SIMD
#if CV_SIMD
for
(
;
j
<=
dn
*
3
-
fsize
*
3
*
4
;
j
+=
fsize
*
3
*
4
)
for
(
;
j
<=
dn
*
3
-
fsize
*
3
*
4
;
j
+=
fsize
*
3
*
4
)
{
{
...
...
modules/imgproc/src/color_lab.cpp
View file @
aaf56c28
...
@@ -3266,7 +3266,7 @@ struct RGB2Luv_b
...
@@ -3266,7 +3266,7 @@ struct RGB2Luv_b
return
;
return
;
}
}
int
i
,
j
,
scn
=
srccn
;
int
scn
=
srccn
;
#if CV_SIMD
#if CV_SIMD
float
CV_DECL_ALIGNED
(
CV_SIMD_WIDTH
)
buf
[
bufChannels
*
BLOCK_SIZE
];
float
CV_DECL_ALIGNED
(
CV_SIMD_WIDTH
)
buf
[
bufChannels
*
BLOCK_SIZE
];
#else
#else
...
@@ -3295,16 +3295,16 @@ struct RGB2Luv_b
...
@@ -3295,16 +3295,16 @@ struct RGB2Luv_b
}
}
#endif
#endif
for
(
i
=
0
;
i
<
n
;
i
+=
BLOCK_SIZE
,
dst
+=
BLOCK_SIZE
*
bufChannels
)
for
(
int
i
=
0
;
i
<
n
;
i
+=
BLOCK_SIZE
,
dst
+=
BLOCK_SIZE
*
bufChannels
)
{
{
int
dn
=
std
::
min
(
n
-
i
,
(
int
)
BLOCK_SIZE
);
int
dn
=
std
::
min
(
n
-
i
,
(
int
)
BLOCK_SIZE
);
j
=
0
;
static
const
softfloat
f255inv
=
softfloat
::
one
()
/
f255
;
static
const
softfloat
f255inv
=
softfloat
::
one
()
/
f255
;
#if CV_SIMD
#if CV_SIMD
v_float32
v255inv
=
vx_setall_f32
((
float
)
f255inv
);
v_float32
v255inv
=
vx_setall_f32
((
float
)
f255inv
);
if
(
scn
==
4
)
if
(
scn
==
4
)
{
{
int
j
=
0
;
static
const
int
nBlock
=
fsize
*
4
;
static
const
int
nBlock
=
fsize
*
4
;
for
(
;
j
<=
dn
*
bufChannels
-
nBlock
*
3
;
for
(
;
j
<=
dn
*
bufChannels
-
nBlock
*
3
;
j
+=
nBlock
*
3
,
src
+=
nBlock
*
4
)
j
+=
nBlock
*
3
,
src
+=
nBlock
*
4
)
...
@@ -3334,9 +3334,16 @@ struct RGB2Luv_b
...
@@ -3334,9 +3334,16 @@ struct RGB2Luv_b
v_store_interleave
(
buf
+
j
+
k
*
3
*
fsize
,
f
[
0
*
4
+
k
],
f
[
1
*
4
+
k
],
f
[
2
*
4
+
k
]);
v_store_interleave
(
buf
+
j
+
k
*
3
*
fsize
,
f
[
0
*
4
+
k
],
f
[
1
*
4
+
k
],
f
[
2
*
4
+
k
]);
}
}
}
}
for
(
;
j
<
dn
*
bufChannels
;
j
+=
bufChannels
,
src
+=
4
)
{
buf
[
j
]
=
(
float
)(
src
[
0
]
*
((
float
)
f255inv
));
buf
[
j
+
1
]
=
(
float
)(
src
[
1
]
*
((
float
)
f255inv
));
buf
[
j
+
2
]
=
(
float
)(
src
[
2
]
*
((
float
)
f255inv
));
}
}
}
else
// scn == 3
else
// scn == 3
{
{
int
j
=
0
;
static
const
int
nBlock
=
fsize
*
2
;
static
const
int
nBlock
=
fsize
*
2
;
for
(
;
j
<=
dn
*
bufChannels
-
nBlock
;
for
(
;
j
<=
dn
*
bufChannels
-
nBlock
;
j
+=
nBlock
,
src
+=
nBlock
)
j
+=
nBlock
,
src
+=
nBlock
)
...
@@ -3348,17 +3355,23 @@ struct RGB2Luv_b
...
@@ -3348,17 +3355,23 @@ struct RGB2Luv_b
v_store_aligned
(
buf
+
j
+
0
*
fsize
,
v_cvt_f32
(
q0
)
*
v255inv
);
v_store_aligned
(
buf
+
j
+
0
*
fsize
,
v_cvt_f32
(
q0
)
*
v255inv
);
v_store_aligned
(
buf
+
j
+
1
*
fsize
,
v_cvt_f32
(
q1
)
*
v255inv
);
v_store_aligned
(
buf
+
j
+
1
*
fsize
,
v_cvt_f32
(
q1
)
*
v255inv
);
}
}
for
(
;
j
<
dn
*
bufChannels
;
j
++
,
src
++
)
{
buf
[
j
]
=
(
float
)(
src
[
0
]
*
((
float
)
f255inv
));
}
}
}
#e
ndif
#e
lse
for
(
;
j
<
dn
*
bufChannels
;
j
+=
bufChannels
,
src
+=
scn
)
for
(
int
j
=
0
;
j
<
dn
*
bufChannels
;
j
+=
bufChannels
,
src
+=
scn
)
{
{
buf
[
j
]
=
(
float
)(
src
[
0
]
*
((
float
)
f255inv
));
buf
[
j
]
=
(
float
)(
src
[
0
]
*
((
float
)
f255inv
));
buf
[
j
+
1
]
=
(
float
)(
src
[
1
]
*
((
float
)
f255inv
));
buf
[
j
+
1
]
=
(
float
)(
src
[
1
]
*
((
float
)
f255inv
));
buf
[
j
+
2
]
=
(
float
)(
src
[
2
]
*
((
float
)
f255inv
));
buf
[
j
+
2
]
=
(
float
)(
src
[
2
]
*
((
float
)
f255inv
));
}
}
#endif
fcvt
(
buf
,
buf
,
dn
);
fcvt
(
buf
,
buf
,
dn
);
j
=
0
;
int
j
=
0
;
#if CV_SIMD
#if CV_SIMD
for
(
;
j
<=
dn
*
3
-
fsize
*
3
*
4
;
j
+=
fsize
*
3
*
4
)
for
(
;
j
<=
dn
*
3
-
fsize
*
3
*
4
;
j
+=
fsize
*
3
*
4
)
...
@@ -3389,7 +3402,7 @@ struct RGB2Luv_b
...
@@ -3389,7 +3402,7 @@ struct RGB2Luv_b
#endif
#endif
for
(
;
j
<
dn
*
3
;
j
+=
3
)
for
(
;
j
<
dn
*
3
;
j
+=
3
)
{
{
dst
[
j
]
=
saturate_cast
<
uchar
>
(
buf
[
j
]
*
(
float
)
fL
);
dst
[
j
+
0
]
=
saturate_cast
<
uchar
>
(
buf
[
j
+
0
]
*
(
float
)
fL
);
dst
[
j
+
1
]
=
saturate_cast
<
uchar
>
(
buf
[
j
+
1
]
*
(
float
)
fu
+
(
float
)
su
);
dst
[
j
+
1
]
=
saturate_cast
<
uchar
>
(
buf
[
j
+
1
]
*
(
float
)
fu
+
(
float
)
su
);
dst
[
j
+
2
]
=
saturate_cast
<
uchar
>
(
buf
[
j
+
2
]
*
(
float
)
fv
+
(
float
)
sv
);
dst
[
j
+
2
]
=
saturate_cast
<
uchar
>
(
buf
[
j
+
2
]
*
(
float
)
fv
+
(
float
)
sv
);
}
}
...
...
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