Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
bfd61cf2
Commit
bfd61cf2
authored
Sep 17, 2011
by
Davis King
Browse files
Just renamed get_scales() to get_hash_bin_sizes() to make things more clear.
parent
bcd9a781
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
35 deletions
+42
-35
dlib/image_keypoint/hashed_feature_image.h
dlib/image_keypoint/hashed_feature_image.h
+28
-22
dlib/image_keypoint/hashed_feature_image_abstract.h
dlib/image_keypoint/hashed_feature_image_abstract.h
+14
-13
No files found.
dlib/image_keypoint/hashed_feature_image.h
View file @
bfd61cf2
...
...
@@ -21,11 +21,11 @@ namespace dlib
{
/*!
INITIAL VALUE
-
scal
es == logspace(-1, 1, 3)
-
inv_bin_siz
es == logspace(-1, 1, 3)
- num_dims == 1000
CONVENTION
-
scal
es.size() > 0
-
inv_bin_siz
es.size() > 0
- num_dims == get_num_dimensions()
- if (has_image_statistics()) then
- rs[i] == the statistics of feature element i. I.e. the stats of fe(r,c)(i)
...
...
@@ -44,11 +44,11 @@ namespace dlib
void
clear
(
);
void
set_
scal
es
(
const
matrix
<
double
,
1
,
0
>&
new_scal
es
void
set_
hash_bin_siz
es
(
const
matrix
<
double
,
1
,
0
>&
bin_siz
es
);
const
matrix
<
double
,
1
,
0
>
&
get_
scal
es
(
const
matrix
<
double
,
1
,
0
>
get_
hash_bin_siz
es
(
)
const
;
template
<
...
...
@@ -136,7 +136,7 @@ namespace dlib
feature_extractor
fe
;
typename
feature_extractor
::
descriptor_type
inv_stddev
;
std
::
vector
<
running_stats
<
double
>
>
rs
;
matrix
<
double
,
1
,
0
>
scal
es
;
matrix
<
double
,
1
,
0
>
inv_bin_siz
es
;
long
num_dims
;
// Transient variables. These are here just so they don't have to get constructed over
...
...
@@ -159,7 +159,7 @@ namespace dlib
serialize
(
item
.
fe
,
out
);
serialize
(
item
.
inv_stddev
,
out
);
serialize
(
item
.
rs
,
out
);
serialize
(
item
.
scal
es
,
out
);
serialize
(
item
.
inv_bin_siz
es
,
out
);
serialize
(
item
.
num_dims
,
out
);
}
...
...
@@ -172,7 +172,7 @@ namespace dlib
deserialize
(
item
.
fe
,
in
);
deserialize
(
item
.
inv_stddev
,
in
);
deserialize
(
item
.
rs
,
in
);
deserialize
(
item
.
scal
es
,
in
);
deserialize
(
item
.
inv_bin_siz
es
,
in
);
deserialize
(
item
.
num_dims
,
in
);
}
...
...
@@ -190,7 +190,7 @@ namespace dlib
)
:
num_dims
(
1000
)
{
scal
es
=
logspace
(
-
1
,
1
,
3
);
inv_bin_siz
es
=
logspace
(
-
1
,
1
,
3
);
}
// ----------------------------------------------------------------------------------------
...
...
@@ -204,7 +204,7 @@ namespace dlib
{
fe
.
clear
();
inv_stddev
=
0
;
scal
es
=
logspace
(
-
1
,
1
,
3
);
inv_bin_siz
es
=
logspace
(
-
1
,
1
,
3
);
rs
.
clear
();
num_dims
=
1000
;
}
...
...
@@ -215,18 +215,24 @@ namespace dlib
typename
feature_extractor
>
void
hashed_feature_image
<
feature_extractor
>::
set_
scal
es
(
const
matrix
<
double
,
1
,
0
>&
new_scal
es
set_
hash_bin_siz
es
(
const
matrix
<
double
,
1
,
0
>&
bin_siz
es
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
new_scal
es
.
size
()
>
0
,
"
\t
void hashed_feature_image::set_
scal
es()"
DLIB_ASSERT
(
bin_siz
es
.
size
()
>
0
,
"
\t
void hashed_feature_image::set_
hash_bin_siz
es()"
<<
"
\n\t
size of new_scales should not be zero"
<<
"
\n\t
this: "
<<
this
);
DLIB_ASSERT
(
min
(
bin_sizes
)
>
0
,
"
\t
void hashed_feature_image::set_hash_bin_sizes()"
<<
"
\n\t
All bins must have sizes greater than zero."
<<
"
\n\t
min(bin_sizes): "
<<
min
(
bin_sizes
)
<<
"
\n\t
this: "
<<
this
);
scales
=
new_scal
es
;
inv_bin_sizes
=
reciprocal
(
bin_siz
es
)
;
}
// ----------------------------------------------------------------------------------------
...
...
@@ -234,11 +240,11 @@ namespace dlib
template
<
typename
feature_extractor
>
const
matrix
<
double
,
1
,
0
>
&
hashed_feature_image
<
feature_extractor
>::
get_
scal
es
(
const
matrix
<
double
,
1
,
0
>
hashed_feature_image
<
feature_extractor
>::
get_
hash_bin_siz
es
(
)
const
{
return
scal
es
;
return
reciprocal
(
inv_bin_siz
es
)
;
}
// ----------------------------------------------------------------------------------------
...
...
@@ -313,7 +319,7 @@ namespace dlib
{
rs
=
item
.
rs
;
inv_stddev
=
item
.
inv_stddev
;
scales
=
item
.
scal
es
;
inv_bin_sizes
=
item
.
inv_bin_siz
es
;
fe
.
copy_configuration
(
item
.
fe
);
num_dims
=
item
.
num_dims
;
}
...
...
@@ -441,15 +447,15 @@ namespace dlib
<<
"
\n\t
this: "
<<
this
);
hash_feats
.
resize
(
scal
es
.
size
());
hash_feats
.
resize
(
inv_bin_siz
es
.
size
());
if
(
has_image_statistics
())
scaled_feats
=
pointwise_multiply
(
fe
(
row
,
col
),
inv_stddev
);
else
scaled_feats
=
fe
(
row
,
col
);
for
(
long
i
=
0
;
i
<
scal
es
.
size
();
++
i
)
for
(
long
i
=
0
;
i
<
inv_bin_siz
es
.
size
();
++
i
)
{
quantized_feats
=
matrix_cast
<
int32
>
(
scal
es
(
i
)
*
scaled_feats
);
quantized_feats
=
matrix_cast
<
int32
>
(
inv_bin_siz
es
(
i
)
*
scaled_feats
);
hash_feats
[
i
]
=
std
::
make_pair
(
hash
(
quantized_feats
)
%
num_dims
,
1
);
}
return
hash_feats
;
...
...
dlib/image_keypoint/hashed_feature_image_abstract.h
View file @
bfd61cf2
...
...
@@ -24,7 +24,7 @@ namespace dlib
INITIAL VALUE
- size() == 0
- get_num_dimensions() == 1000
- get_
scal
es() == logspace(-1,1,3)
- get_
hash_bin_siz
es() == logspace(-1,1,3)
WHAT THIS OBJECT REPRESENTS
This object is a tool for performing image feature extraction. In
...
...
@@ -68,30 +68,31 @@ namespace dlib
- this object will have its initial value
!*/
void
set_
scal
es
(
const
matrix
<
double
,
1
,
0
>&
new_scal
es
void
set_
hash_bin_siz
es
(
const
matrix
<
double
,
1
,
0
>&
bin_siz
es
);
/*!
requires
- new_scales.size() > 0
- bin_sizes.size() > 0
- min(bin_sizes) > 0
ensures
- #get_
scales() == new_scal
es
- #get_
hash_bin_sizes() == bin_siz
es
!*/
const
matrix
<
double
,
1
,
0
>
&
get_
scal
es
(
const
matrix
<
double
,
1
,
0
>
get_
hash_bin_siz
es
(
)
const
;
/*!
ensures
- When a feature vector from BASE_FE is hashed, it is hashed into exactly
get_
scal
es().size() hash bins. Each hash is computed as follows:
get_
hash_bin_siz
es().size() hash bins. Each hash is computed as follows:
- First normalize the feature vector.
- Then
multiply
it by an element of get_
scal
es().
- Then
divide
it by an element of get_
hash_bin_siz
es().
- Then convert the resulting vector to a vector of dlib::int32.
- Finally, hash the integer vector into a hash bin.
- The size of the numbers in get_
scal
es() determines how
"
big
"
the hash
bins are.
A very small scal
e value would result in all input vectors being hashed
into the
same bin, while
larger scale
values would result in only similar vectors
falling into the same bins. However, a
scale
value too
large
would result in
- The size of the numbers in get_
hash_bin_siz
es() determines how big the hash
bins are. A very larg
e value would result in all input vectors being hashed
into the
same bin, while
smaller
values would result in only similar vectors
falling into the same bins. However, a value too
small
would result in
all vectors going into different bins. In this case, the bins are too fine
grained.
!*/
...
...
@@ -199,7 +200,7 @@ namespace dlib
ensures
- hashes BASE_FE(row,col) and returns the resulting indicator vector.
- Returns a vector V such that:
- V.size() == get_
scal
es().size()
- V.size() == get_
hash_bin_siz
es().size()
- for all valid i: 0 <= V[i].first < get_num_dimensions()
- if (BASE_FE(row,col) hashes into bin B) then
- V contains an element with .first == B and .second == 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