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
bb679f97
Commit
bb679f97
authored
Sep 21, 2017
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9653 from dkurt:thresh_16u
parents
2ad27f57
fa109b94
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
3 deletions
+61
-3
thresh.cpp
modules/imgproc/src/thresh.cpp
+0
-0
test_thresh.cpp
modules/imgproc/test/test_thresh.cpp
+61
-3
No files found.
modules/imgproc/src/thresh.cpp
View file @
bb679f97
This diff is collapsed.
Click to expand it.
modules/imgproc/test/test_thresh.cpp
View file @
bb679f97
...
...
@@ -75,9 +75,9 @@ void CV_ThreshTest::get_test_array_types_and_sizes( int test_case_idx,
vector
<
vector
<
Size
>
>&
sizes
,
vector
<
vector
<
int
>
>&
types
)
{
RNG
&
rng
=
ts
->
get_rng
();
int
depth
=
cvtest
::
randInt
(
rng
)
%
4
,
cn
=
cvtest
::
randInt
(
rng
)
%
4
+
1
;
int
depth
=
cvtest
::
randInt
(
rng
)
%
5
,
cn
=
cvtest
::
randInt
(
rng
)
%
4
+
1
;
cvtest
::
ArrayTest
::
get_test_array_types_and_sizes
(
test_case_idx
,
sizes
,
types
);
depth
=
depth
==
0
?
CV_8U
:
depth
==
1
?
CV_16S
:
depth
==
2
?
CV_32F
:
CV_64F
;
depth
=
depth
==
0
?
CV_8U
:
depth
==
1
?
CV_16S
:
depth
==
2
?
CV_
16U
:
depth
==
3
?
CV_
32F
:
CV_64F
;
types
[
INPUT
][
0
]
=
types
[
OUTPUT
][
0
]
=
types
[
REF_OUTPUT
][
0
]
=
CV_MAKETYPE
(
depth
,
cn
);
thresh_type
=
cvtest
::
randInt
(
rng
)
%
5
;
...
...
@@ -98,6 +98,15 @@ void CV_ThreshTest::get_test_array_types_and_sizes( int test_case_idx,
if
(
cvtest
::
randInt
(
rng
)
%
4
==
0
)
max_val
=
(
double
)
SHRT_MAX
;
}
else
if
(
depth
==
CV_16U
)
{
double
min_val
=
-
100.
f
;
max_val
=
USHRT_MAX
+
100.
f
;
thresh_val
=
(
cvtest
::
randReal
(
rng
)
*
(
max_val
-
min_val
)
+
min_val
);
max_val
=
(
cvtest
::
randReal
(
rng
)
*
(
max_val
-
min_val
)
+
min_val
);
if
(
cvtest
::
randInt
(
rng
)
%
4
==
0
)
max_val
=
(
double
)
USHRT_MAX
;
}
else
{
thresh_val
=
(
cvtest
::
randReal
(
rng
)
*
1000.
-
500.
);
...
...
@@ -138,13 +147,18 @@ static void test_threshold( const Mat& _src, Mat& _dst,
ithresh2
=
saturate_cast
<
short
>
(
ithresh
);
imaxval
=
saturate_cast
<
short
>
(
maxval
);
}
else
if
(
depth
==
CV_16U
)
{
ithresh2
=
saturate_cast
<
ushort
>
(
ithresh
);
imaxval
=
saturate_cast
<
ushort
>
(
maxval
);
}
else
{
ithresh2
=
cvRound
(
ithresh
);
imaxval
=
cvRound
(
maxval
);
}
assert
(
depth
==
CV_8U
||
depth
==
CV_16S
||
depth
==
CV_32F
||
depth
==
CV_64F
);
assert
(
depth
==
CV_8U
||
depth
==
CV_16S
||
depth
==
CV_
16U
||
depth
==
CV_
32F
||
depth
==
CV_64F
);
switch
(
thresh_type
)
{
...
...
@@ -165,6 +179,13 @@ static void test_threshold( const Mat& _src, Mat& _dst,
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
(
short
)(
src
[
j
]
>
ithresh
?
imaxval
:
0
);
}
else
if
(
depth
==
CV_16U
)
{
const
ushort
*
src
=
_src
.
ptr
<
ushort
>
(
i
);
ushort
*
dst
=
_dst
.
ptr
<
ushort
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
(
ushort
)(
src
[
j
]
>
ithresh
?
imaxval
:
0
);
}
else
if
(
depth
==
CV_32F
)
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
...
...
@@ -198,6 +219,13 @@ static void test_threshold( const Mat& _src, Mat& _dst,
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
(
short
)(
src
[
j
]
>
ithresh
?
0
:
imaxval
);
}
else
if
(
depth
==
CV_16U
)
{
const
ushort
*
src
=
_src
.
ptr
<
ushort
>
(
i
);
ushort
*
dst
=
_dst
.
ptr
<
ushort
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
dst
[
j
]
=
(
ushort
)(
src
[
j
]
>
ithresh
?
0
:
imaxval
);
}
else
if
(
depth
==
CV_32F
)
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
...
...
@@ -237,6 +265,16 @@ static void test_threshold( const Mat& _src, Mat& _dst,
dst
[
j
]
=
(
short
)(
s
>
ithresh
?
ithresh2
:
s
);
}
}
else
if
(
depth
==
CV_16U
)
{
const
ushort
*
src
=
_src
.
ptr
<
ushort
>
(
i
);
ushort
*
dst
=
_dst
.
ptr
<
ushort
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
int
s
=
src
[
j
];
dst
[
j
]
=
(
ushort
)(
s
>
ithresh
?
ithresh2
:
s
);
}
}
else
if
(
depth
==
CV_32F
)
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
...
...
@@ -282,6 +320,16 @@ static void test_threshold( const Mat& _src, Mat& _dst,
dst
[
j
]
=
(
short
)(
s
>
ithresh
?
s
:
0
);
}
}
else
if
(
depth
==
CV_16U
)
{
const
ushort
*
src
=
_src
.
ptr
<
ushort
>
(
i
);
ushort
*
dst
=
_dst
.
ptr
<
ushort
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
int
s
=
src
[
j
];
dst
[
j
]
=
(
ushort
)(
s
>
ithresh
?
s
:
0
);
}
}
else
if
(
depth
==
CV_32F
)
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
...
...
@@ -327,6 +375,16 @@ static void test_threshold( const Mat& _src, Mat& _dst,
dst
[
j
]
=
(
short
)(
s
>
ithresh
?
0
:
s
);
}
}
else
if
(
depth
==
CV_16U
)
{
const
ushort
*
src
=
_src
.
ptr
<
ushort
>
(
i
);
ushort
*
dst
=
_dst
.
ptr
<
ushort
>
(
i
);
for
(
j
=
0
;
j
<
width_n
;
j
++
)
{
int
s
=
src
[
j
];
dst
[
j
]
=
(
ushort
)(
s
>
ithresh
?
0
:
s
);
}
}
else
if
(
depth
==
CV_32F
)
{
const
float
*
src
=
_src
.
ptr
<
float
>
(
i
);
...
...
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