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
869dda41
Commit
869dda41
authored
Jul 22, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4204 from gladilov-gleb:minMaxLocBugFix
parents
67158b12
07de67c3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
11 deletions
+34
-11
stat.cpp
modules/core/src/stat.cpp
+10
-2
test_arithm.cpp
modules/core/test/test_arithm.cpp
+18
-0
ts_func.cpp
modules/ts/src/ts_func.cpp
+6
-9
No files found.
modules/core/src/stat.cpp
View file @
869dda41
...
...
@@ -1097,8 +1097,8 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
size_t
minidx
=
0
,
maxidx
=
0
;
int
iminval
=
INT_MAX
,
imaxval
=
INT_MIN
;
float
fminval
=
FLT_MAX
,
fmaxval
=
-
FLT_MAX
;
double
dminval
=
DBL_MAX
,
dmaxval
=
-
DBL_MAX
;
float
fminval
=
std
::
numeric_limits
<
float
>::
infinity
(),
fmaxval
=
-
fminval
;
double
dminval
=
std
::
numeric_limits
<
double
>::
infinity
(),
dmaxval
=
-
dminval
;
size_t
startidx
=
1
;
int
*
minval
=
&
iminval
,
*
maxval
=
&
imaxval
;
int
planeSize
=
(
int
)
it
.
size
*
cn
;
...
...
@@ -1111,6 +1111,14 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
for
(
size_t
i
=
0
;
i
<
it
.
nplanes
;
i
++
,
++
it
,
startidx
+=
planeSize
)
func
(
ptrs
[
0
],
ptrs
[
1
],
minval
,
maxval
,
&
minidx
,
&
maxidx
,
planeSize
,
startidx
);
if
(
!
src
.
empty
()
&&
mask
.
empty
())
{
if
(
minidx
==
0
)
minidx
=
1
;
if
(
maxidx
==
0
)
maxidx
=
1
;
}
if
(
minidx
==
0
)
dminval
=
dmaxval
=
0
;
else
if
(
depth
==
CV_32F
)
...
...
modules/core/test/test_arithm.cpp
View file @
869dda41
...
...
@@ -1792,3 +1792,21 @@ INSTANTIATE_TEST_CASE_P(Arithm, SubtractOutputMatNotEmpty, testing::Combine(
testing
::
Values
(
perf
::
MatType
(
CV_8UC1
),
CV_8UC3
,
CV_8UC4
,
CV_16SC1
,
CV_16SC3
),
testing
::
Values
(
-
1
,
CV_16S
,
CV_32S
,
CV_32F
),
testing
::
Bool
()));
TEST
(
MinMaxLoc
,
Mat_IntMax_Without_Mask
)
{
Mat_
<
int
>
mat
(
50
,
50
);
int
iMaxVal
=
numeric_limits
<
int
>::
max
();
mat
.
setTo
(
iMaxVal
);
double
min
,
max
;
Point
minLoc
,
maxLoc
;
minMaxLoc
(
mat
,
&
min
,
&
max
,
&
minLoc
,
&
maxLoc
,
Mat
());
ASSERT_EQ
(
iMaxVal
,
min
);
ASSERT_EQ
(
iMaxVal
,
max
);
ASSERT_EQ
(
Point
(
0
,
0
),
minLoc
);
ASSERT_EQ
(
Point
(
0
,
0
),
maxLoc
);
}
modules/ts/src/ts_func.cpp
View file @
869dda41
...
...
@@ -977,12 +977,12 @@ minMaxLoc_(const _Tp* src, size_t total, size_t startidx,
for
(
size_t
i
=
0
;
i
<
total
;
i
++
)
{
_Tp
val
=
src
[
i
];
if
(
minval
>
val
)
if
(
minval
>
val
||
!
minpos
)
{
minval
=
val
;
minpos
=
startidx
+
i
;
}
if
(
maxval
<
val
)
if
(
maxval
<
val
||
!
maxpos
)
{
maxval
=
val
;
maxpos
=
startidx
+
i
;
...
...
@@ -994,12 +994,12 @@ minMaxLoc_(const _Tp* src, size_t total, size_t startidx,
for
(
size_t
i
=
0
;
i
<
total
;
i
++
)
{
_Tp
val
=
src
[
i
];
if
(
minval
>
val
&&
mask
[
i
]
)
if
(
(
minval
>
val
||
!
minpos
)
&&
mask
[
i
]
)
{
minval
=
val
;
minpos
=
startidx
+
i
;
}
if
(
maxval
<
val
&&
mask
[
i
]
)
if
(
(
maxval
<
val
||
!
maxpos
)
&&
mask
[
i
]
)
{
maxval
=
val
;
maxpos
=
startidx
+
i
;
...
...
@@ -1046,8 +1046,8 @@ void minMaxLoc(const Mat& src, double* _minval, double* _maxval,
size_t
startidx
=
1
,
total
=
planes
[
0
].
total
();
size_t
i
,
nplanes
=
it
.
nplanes
;
int
depth
=
src
.
depth
();
double
m
axval
=
depth
<
CV_32F
?
INT_MIN
:
depth
==
CV_32F
?
-
FLT_MAX
:
-
DBL_MAX
;
double
m
inval
=
depth
<
CV_32F
?
INT_MAX
:
depth
==
CV_32F
?
FLT_MAX
:
DBL_MAX
;
double
m
inval
=
0
;
double
m
axval
=
0
;
size_t
maxidx
=
0
,
minidx
=
0
;
for
(
i
=
0
;
i
<
nplanes
;
i
++
,
++
it
,
startidx
+=
total
)
...
...
@@ -1090,9 +1090,6 @@ void minMaxLoc(const Mat& src, double* _minval, double* _maxval,
}
}
if
(
minidx
==
0
)
minval
=
maxval
=
0
;
if
(
_maxval
)
*
_maxval
=
maxval
;
if
(
_minval
)
...
...
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