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
7ec59fc0
Commit
7ec59fc0
authored
Sep 17, 2017
by
Christof Kaufmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert changes of mean and meanStdDev
parent
46a668c5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
39 deletions
+19
-39
core.hpp
modules/core/include/opencv2/core.hpp
+2
-2
stat.cpp
modules/core/src/stat.cpp
+0
-0
test_arithm.cpp
modules/core/test/test_arithm.cpp
+2
-2
ts_func.cpp
modules/ts/src/ts_func.cpp
+15
-35
No files found.
modules/core/include/opencv2/core.hpp
View file @
7ec59fc0
...
...
@@ -608,7 +608,7 @@ CV_EXPORTS_W void findNonZero( InputArray src, OutputArray idx );
The function cv::mean calculates the mean value M of array elements,
independently for each channel, and return it:
\f[\begin{array}{l} N
_c = \sum _{I: \; {\texttt{mask} (I)_c} \ne 0} 1 \\ M_c = \left ( \sum _{I: \; {\texttt{mask} (I)_c} \ne 0}{ \texttt{src} (I)_c} \right )/N_c
\end{array}\f]
\f[\begin{array}{l} N
= \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c = \left ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N
\end{array}\f]
When all the mask elements are 0's, the function returns Scalar::all(0)
@param src input array that should have from 1 to 4 channels so that the result can be stored in
Scalar_ .
...
...
@@ -622,7 +622,7 @@ CV_EXPORTS_W Scalar mean(InputArray src, InputArray mask = noArray());
The function cv::meanStdDev calculates the mean and the standard deviation M
of array elements independently for each channel and returns it via the
output parameters:
\f[\begin{array}{l} N
_c = \sum _{I, {\texttt{mask} (I)_c} \ne 0} 1 \\ \texttt{mean} _c = \frac{\sum_{ I: \; {\texttt{mask} (I)_c} \ne 0} \texttt{src} (I)_c}{N_c} \\ \texttt{stddev} _c = \sqrt{\frac{\sum_{ I: \; {\texttt{mask} (I)_c} \ne 0} \left ( \texttt{src} (I)_c - \texttt{mean} _c \right )^2}{N_c
}} \end{array}\f]
\f[\begin{array}{l} N
= \sum _{I, \texttt{mask} (I) \ne 0} 1 \\ \texttt{mean} _c = \frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \texttt{src} (I)_c}{N} \\ \texttt{stddev} _c = \sqrt{\frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \left ( \texttt{src} (I)_c - \texttt{mean} _c \right )^2}{N
}} \end{array}\f]
When all the mask elements are 0's, the function returns
mean=stddev=Scalar::all(0).
@note The calculated standard deviation is only the diagonal of the
...
...
modules/core/src/stat.cpp
View file @
7ec59fc0
This diff is collapsed.
Click to expand it.
modules/core/test/test_arithm.cpp
View file @
7ec59fc0
...
...
@@ -1162,7 +1162,7 @@ struct CartToPolarToCartOp : public BaseElemWiseOp
struct
MeanOp
:
public
BaseElemWiseOp
{
MeanOp
()
:
BaseElemWiseOp
(
1
,
FIX_ALPHA
+
FIX_BETA
+
FIX_GAMMA
+
SUPPORT_MASK
+
S
UPPORT_MULTICHANNELMASK
+
S
CALAR_OUTPUT
,
1
,
1
,
Scalar
::
all
(
0
))
MeanOp
()
:
BaseElemWiseOp
(
1
,
FIX_ALPHA
+
FIX_BETA
+
FIX_GAMMA
+
SUPPORT_MASK
+
SCALAR_OUTPUT
,
1
,
1
,
Scalar
::
all
(
0
))
{
context
=
3
;
};
...
...
@@ -1244,7 +1244,7 @@ struct MeanStdDevOp : public BaseElemWiseOp
Scalar
sqmeanRef
;
int
cn
;
MeanStdDevOp
()
:
BaseElemWiseOp
(
1
,
FIX_ALPHA
+
FIX_BETA
+
FIX_GAMMA
+
SUPPORT_MASK
+
S
UPPORT_MULTICHANNELMASK
+
S
CALAR_OUTPUT
,
1
,
1
,
Scalar
::
all
(
0
))
MeanStdDevOp
()
:
BaseElemWiseOp
(
1
,
FIX_ALPHA
+
FIX_BETA
+
FIX_GAMMA
+
SUPPORT_MASK
+
SCALAR_OUTPUT
,
1
,
1
,
Scalar
::
all
(
0
))
{
cn
=
0
;
context
=
7
;
...
...
modules/ts/src/ts_func.cpp
View file @
7ec59fc0
...
...
@@ -2598,11 +2598,11 @@ void divide(const Mat& src1, const Mat& src2, Mat& dst, double scale)
template
<
typename
_Tp
>
static
void
mean_
(
const
_Tp
*
src
,
const
uchar
*
mask
,
size_t
total
,
int
cn
,
int
mcn
,
Scalar
&
sum
,
Scalar_
<
int
>
&
nz
)
mean_
(
const
_Tp
*
src
,
const
uchar
*
mask
,
size_t
total
,
int
cn
,
Scalar
&
sum
,
int
&
nz
)
{
if
(
!
mask
)
{
nz
+=
Scalar_
<
int
>::
all
((
int
)
total
)
;
nz
+=
(
int
)
total
;
total
*=
cn
;
for
(
size_t
i
=
0
;
i
<
total
;
i
+=
cn
)
{
...
...
@@ -2610,41 +2610,23 @@ mean_(const _Tp* src, const uchar* mask, size_t total, int cn, int mcn, Scalar&
sum
[
c
]
+=
src
[
i
+
c
];
}
}
else
if
(
mcn
==
1
)
else
{
for
(
size_t
i
=
0
;
i
<
total
;
i
++
)
if
(
mask
[
i
]
)
{
nz
++
;
for
(
int
c
=
0
;
c
<
cn
;
c
++
)
{
nz
[
c
]
++
;
sum
[
c
]
+=
src
[
i
*
cn
+
c
];
}
}
}
else
{
total
*=
cn
;
for
(
size_t
i
=
0
;
i
<
total
;
i
+=
cn
)
{
for
(
int
c
=
0
;
c
<
cn
;
c
++
)
{
if
(
mask
[
i
+
c
]
)
{
nz
[
c
]
++
;
sum
[
c
]
+=
src
[
i
+
c
];
}
}
}
}
}
Scalar
mean
(
const
Mat
&
src
,
const
Mat
&
mask
)
{
CV_Assert
(
mask
.
empty
()
||
(
mask
.
depth
()
==
CV_8U
&&
mask
.
size
==
src
.
size
&&
(
mask
.
channels
()
==
1
||
mask
.
channels
()
==
src
.
channels
())));
CV_Assert
(
mask
.
empty
()
||
(
mask
.
type
()
==
CV_8U
&&
mask
.
size
==
src
.
size
));
Scalar
sum
;
Scalar_
<
int
>
nz
=
Scalar_
<
int
>::
all
(
0
)
;
int
nz
=
0
;
const
Mat
*
arrays
[]
=
{
&
src
,
&
mask
,
0
};
Mat
planes
[
2
];
...
...
@@ -2652,7 +2634,7 @@ Scalar mean(const Mat& src, const Mat& mask)
NAryMatIterator
it
(
arrays
,
planes
);
size_t
total
=
planes
[
0
].
total
();
size_t
i
,
nplanes
=
it
.
nplanes
;
int
c
,
depth
=
src
.
depth
(),
cn
=
src
.
channels
(),
mcn
=
mask
.
channels
();
int
depth
=
src
.
depth
(),
cn
=
src
.
channels
();
for
(
i
=
0
;
i
<
nplanes
;
i
++
,
++
it
)
{
...
...
@@ -2662,34 +2644,32 @@ Scalar mean(const Mat& src, const Mat& mask)
switch
(
depth
)
{
case
CV_8U
:
mean_
((
const
uchar
*
)
sptr
,
mptr
,
total
,
cn
,
mcn
,
sum
,
nz
);
mean_
((
const
uchar
*
)
sptr
,
mptr
,
total
,
cn
,
sum
,
nz
);
break
;
case
CV_8S
:
mean_
((
const
schar
*
)
sptr
,
mptr
,
total
,
cn
,
mcn
,
sum
,
nz
);
mean_
((
const
schar
*
)
sptr
,
mptr
,
total
,
cn
,
sum
,
nz
);
break
;
case
CV_16U
:
mean_
((
const
ushort
*
)
sptr
,
mptr
,
total
,
cn
,
mcn
,
sum
,
nz
);
mean_
((
const
ushort
*
)
sptr
,
mptr
,
total
,
cn
,
sum
,
nz
);
break
;
case
CV_16S
:
mean_
((
const
short
*
)
sptr
,
mptr
,
total
,
cn
,
mcn
,
sum
,
nz
);
mean_
((
const
short
*
)
sptr
,
mptr
,
total
,
cn
,
sum
,
nz
);
break
;
case
CV_32S
:
mean_
((
const
int
*
)
sptr
,
mptr
,
total
,
cn
,
mcn
,
sum
,
nz
);
mean_
((
const
int
*
)
sptr
,
mptr
,
total
,
cn
,
sum
,
nz
);
break
;
case
CV_32F
:
mean_
((
const
float
*
)
sptr
,
mptr
,
total
,
cn
,
mcn
,
sum
,
nz
);
mean_
((
const
float
*
)
sptr
,
mptr
,
total
,
cn
,
sum
,
nz
);
break
;
case
CV_64F
:
mean_
((
const
double
*
)
sptr
,
mptr
,
total
,
cn
,
mcn
,
sum
,
nz
);
mean_
((
const
double
*
)
sptr
,
mptr
,
total
,
cn
,
sum
,
nz
);
break
;
default
:
CV_Error
(
Error
::
StsUnsupportedFormat
,
""
);
}
}
for
(
c
=
0
;
c
<
cn
;
c
++
)
sum
[
c
]
*=
(
1.
/
std
::
max
(
nz
[
c
],
1
));
return
sum
;
return
sum
*
(
1.
/
std
::
max
(
nz
,
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