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
3bd364fc
Commit
3bd364fc
authored
Apr 25, 2014
by
Adil Ibragimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing accum_dist and operator() mismatching for HellingerDistance and KL_Divergence
parent
32b25de5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
dist.h
modules/flann/include/opencv2/flann/dist.h
+8
-5
No files found.
modules/flann/include/opencv2/flann/dist.h
View file @
3bd364fc
...
@@ -595,7 +595,7 @@ struct HellingerDistance
...
@@ -595,7 +595,7 @@ struct HellingerDistance
typedef
typename
Accumulator
<
T
>::
Type
ResultType
;
typedef
typename
Accumulator
<
T
>::
Type
ResultType
;
/**
/**
* Compute the
histogram intersection
distance
* Compute the
Hellinger
distance
*/
*/
template
<
typename
Iterator1
,
typename
Iterator2
>
template
<
typename
Iterator1
,
typename
Iterator2
>
ResultType
operator
()(
Iterator1
a
,
Iterator2
b
,
size_t
size
,
ResultType
/*worst_dist*/
=
-
1
)
const
ResultType
operator
()(
Iterator1
a
,
Iterator2
b
,
size_t
size
,
ResultType
/*worst_dist*/
=
-
1
)
const
...
@@ -628,7 +628,8 @@ struct HellingerDistance
...
@@ -628,7 +628,8 @@ struct HellingerDistance
template
<
typename
U
,
typename
V
>
template
<
typename
U
,
typename
V
>
inline
ResultType
accum_dist
(
const
U
&
a
,
const
V
&
b
,
int
)
const
inline
ResultType
accum_dist
(
const
U
&
a
,
const
V
&
b
,
int
)
const
{
{
return
sqrt
(
static_cast
<
ResultType
>
(
a
))
-
sqrt
(
static_cast
<
ResultType
>
(
b
));
ResultType
diff
=
sqrt
(
static_cast
<
ResultType
>
(
a
))
-
sqrt
(
static_cast
<
ResultType
>
(
b
));
return
diff
*
diff
;
}
}
};
};
...
@@ -729,9 +730,11 @@ struct KL_Divergence
...
@@ -729,9 +730,11 @@ struct KL_Divergence
inline
ResultType
accum_dist
(
const
U
&
a
,
const
V
&
b
,
int
)
const
inline
ResultType
accum_dist
(
const
U
&
a
,
const
V
&
b
,
int
)
const
{
{
ResultType
result
=
ResultType
();
ResultType
result
=
ResultType
();
ResultType
ratio
=
(
ResultType
)(
a
/
b
);
if
(
*
b
!=
0
)
{
if
(
ratio
>
0
)
{
ResultType
ratio
=
(
ResultType
)(
a
/
b
);
result
=
a
*
log
(
ratio
);
if
(
ratio
>
0
)
{
result
=
a
*
log
(
ratio
);
}
}
}
return
result
;
return
result
;
}
}
...
...
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