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
8441cf70
Commit
8441cf70
authored
Oct 11, 2012
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added function cv::findNonZero (patch #2205)
parent
d72cc06b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
core.hpp
modules/core/include/opencv2/core/core.hpp
+3
-0
stat.cpp
modules/core/src/stat.cpp
+22
-0
No files found.
modules/core/include/opencv2/core/core.hpp
View file @
8441cf70
...
...
@@ -2102,6 +2102,9 @@ CV_EXPORTS_W void LUT(InputArray src, InputArray lut, OutputArray dst,
CV_EXPORTS_AS
(
sumElems
)
Scalar
sum
(
InputArray
src
);
//! computes the number of nonzero array elements
CV_EXPORTS_W
int
countNonZero
(
InputArray
src
);
//! returns the list of locations of non-zero pixels
CV_EXPORTS_W
void
findNonZero
(
InputArray
src
,
OutputArray
idx
);
//! computes mean value of selected array elements
CV_EXPORTS_W
Scalar
mean
(
InputArray
src
,
InputArray
mask
=
noArray
());
//! computes mean value and standard deviation of all or selected array elements
...
...
modules/core/src/stat.cpp
View file @
8441cf70
...
...
@@ -1904,6 +1904,28 @@ void cv::batchDistance( InputArray _src1, InputArray _src2,
}
void
cv
::
findNonZero
(
InputArray
_src
,
OutputArray
_idx
)
{
Mat
src
=
_src
.
getMat
();
CV_Assert
(
src
.
type
()
==
CV_8UC1
);
int
n
=
countNonZero
(
src
);
if
(
_idx
.
kind
()
==
_InputArray
::
MAT
&&
!
_idx
.
getMatRef
().
isContinuous
()
)
_idx
.
release
();
_idx
.
create
(
n
,
1
,
CV_32SC2
);
Mat
idx
=
_idx
.
getMat
();
CV_Assert
(
idx
.
isContinuous
());
Point
*
idx_ptr
=
(
Point
*
)
idx
.
data
;
for
(
int
i
=
0
;
i
<
src
.
rows
;
i
++
)
{
const
uchar
*
bin_ptr
=
src
.
ptr
(
i
);
for
(
int
j
=
0
;
j
<
src
.
cols
;
j
++
)
if
(
bin_ptr
[
j
]
)
*
idx_ptr
++
=
Point
(
j
,
i
);
}
}
CV_IMPL
CvScalar
cvSum
(
const
CvArr
*
srcarr
)
{
cv
::
Scalar
sum
=
cv
::
sum
(
cv
::
cvarrToMat
(
srcarr
,
false
,
true
,
1
));
...
...
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