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
e4f207c4
Commit
e4f207c4
authored
May 17, 2016
by
atinfinity
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed cv::threshold() to support CV_64F
parent
764a1f59
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
thresh.cpp
modules/imgproc/src/thresh.cpp
+85
-0
No files found.
modules/imgproc/src/thresh.cpp
View file @
e4f207c4
...
...
@@ -904,6 +904,85 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type )
}
}
static
void
thresh_64f
(
const
Mat
&
_src
,
Mat
&
_dst
,
double
thresh
,
double
maxval
,
int
type
)
{
int
i
,
j
;
Size
roi
=
_src
.
size
();
roi
.
width
*=
_src
.
channels
();
const
double
*
src
=
_src
.
ptr
<
double
>
();
double
*
dst
=
_dst
.
ptr
<
double
>
();
size_t
src_step
=
_src
.
step
/
sizeof
(
src
[
0
]);
size_t
dst_step
=
_dst
.
step
/
sizeof
(
dst
[
0
]);
if
(
_src
.
isContinuous
()
&&
_dst
.
isContinuous
())
{
roi
.
width
*=
roi
.
height
;
roi
.
height
=
1
;
}
switch
(
type
)
{
case
THRESH_BINARY
:
for
(
i
=
0
;
i
<
roi
.
height
;
i
++
,
src
+=
src_step
,
dst
+=
dst_step
)
{
j
=
0
;
for
(;
j
<
roi
.
width
;
j
++
)
dst
[
j
]
=
src
[
j
]
>
thresh
?
maxval
:
0
;
}
break
;
case
THRESH_BINARY_INV
:
for
(
i
=
0
;
i
<
roi
.
height
;
i
++
,
src
+=
src_step
,
dst
+=
dst_step
)
{
j
=
0
;
for
(;
j
<
roi
.
width
;
j
++
)
dst
[
j
]
=
src
[
j
]
<=
thresh
?
maxval
:
0
;
}
break
;
case
THRESH_TRUNC
:
for
(
i
=
0
;
i
<
roi
.
height
;
i
++
,
src
+=
src_step
,
dst
+=
dst_step
)
{
j
=
0
;
for
(;
j
<
roi
.
width
;
j
++
)
dst
[
j
]
=
std
::
min
(
src
[
j
],
thresh
);
}
break
;
case
THRESH_TOZERO
:
for
(
i
=
0
;
i
<
roi
.
height
;
i
++
,
src
+=
src_step
,
dst
+=
dst_step
)
{
j
=
0
;
for
(;
j
<
roi
.
width
;
j
++
)
{
double
v
=
src
[
j
];
dst
[
j
]
=
v
>
thresh
?
v
:
0
;
}
}
break
;
case
THRESH_TOZERO_INV
:
for
(
i
=
0
;
i
<
roi
.
height
;
i
++
,
src
+=
src_step
,
dst
+=
dst_step
)
{
j
=
0
;
for
(;
j
<
roi
.
width
;
j
++
)
{
double
v
=
src
[
j
];
dst
[
j
]
=
v
<=
thresh
?
v
:
0
;
}
}
break
;
default
:
return
CV_Error
(
CV_StsBadArg
,
""
);
}
}
#ifdef HAVE_IPP
static
bool
ipp_getThreshVal_Otsu_8u
(
const
unsigned
char
*
_src
,
int
step
,
Size
size
,
unsigned
char
&
thresh
)
{
...
...
@@ -1129,6 +1208,10 @@ public:
{
thresh_32f
(
srcStripe
,
dstStripe
,
(
float
)
thresh
,
(
float
)
maxval
,
thresholdType
);
}
else
if
(
srcStripe
.
depth
()
==
CV_64F
)
{
thresh_64f
(
srcStripe
,
dstStripe
,
(
double
)
thresh
,
(
double
)
maxval
,
thresholdType
);
}
}
private
:
...
...
@@ -1269,6 +1352,8 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
}
else
if
(
src
.
depth
()
==
CV_32F
)
;
else
if
(
src
.
depth
()
==
CV_64F
)
;
else
CV_Error
(
CV_StsUnsupportedFormat
,
""
);
...
...
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