Commit 5e7d14f4 authored by Davis King's avatar Davis King

simplified this object a little bit.

parent 02566cc9
...@@ -58,8 +58,6 @@ namespace dlib ...@@ -58,8 +58,6 @@ namespace dlib
const image_type& img const image_type& img
); );
bool has_image_statistics (
) const;
void copy_configuration ( void copy_configuration (
const feature_extractor& item const feature_extractor& item
...@@ -132,6 +130,8 @@ namespace dlib ...@@ -132,6 +130,8 @@ namespace dlib
private: private:
inline bool has_image_statistics (
) const;
feature_extractor fe; feature_extractor fe;
typename feature_extractor::descriptor_type inv_stddev; typename feature_extractor::descriptor_type inv_stddev;
...@@ -431,11 +431,9 @@ namespace dlib ...@@ -431,11 +431,9 @@ namespace dlib
{ {
// make sure requires clause is not broken // make sure requires clause is not broken
DLIB_ASSERT(0 <= row && row < nr() && DLIB_ASSERT(0 <= row && row < nr() &&
0 <= col && col < nc() && 0 <= col && col < nc(),
has_image_statistics() == true,
"\t descriptor_type hashed_feature_image::operator(row,col)" "\t descriptor_type hashed_feature_image::operator(row,col)"
<< "\n\t Invalid inputs were given to this function" << "\n\t Invalid inputs were given to this function"
<< "\n\t has_image_statistics(): " << has_image_statistics()
<< "\n\t row: " << row << "\n\t row: " << row
<< "\n\t col: " << col << "\n\t col: " << col
<< "\n\t nr(): " << nr() << "\n\t nr(): " << nr()
...@@ -444,7 +442,11 @@ namespace dlib ...@@ -444,7 +442,11 @@ namespace dlib
); );
hash_feats.resize(scales.size()); hash_feats.resize(scales.size());
scaled_feats = pointwise_multiply(fe(row,col), inv_stddev); if (has_image_statistics())
scaled_feats = pointwise_multiply(fe(row,col), inv_stddev);
else
scaled_feats = fe(row,col);
for (long i = 0; i < scales.size(); ++i) for (long i = 0; i < scales.size(); ++i)
{ {
quantized_feats = matrix_cast<int32>(scales(i)*scaled_feats); quantized_feats = matrix_cast<int32>(scales(i)*scaled_feats);
......
...@@ -24,7 +24,6 @@ namespace dlib ...@@ -24,7 +24,6 @@ namespace dlib
INITIAL VALUE INITIAL VALUE
- size() == 0 - size() == 0
- get_num_dimensions() == 1000 - get_num_dimensions() == 1000
- has_image_statistics() == false
- get_scales() == logspace(-1,1,3) - get_scales() == logspace(-1,1,3)
WHAT THIS OBJECT REPRESENTS WHAT THIS OBJECT REPRESENTS
...@@ -77,10 +76,10 @@ namespace dlib ...@@ -77,10 +76,10 @@ namespace dlib
ensures ensures
- When a feature vector from BASE_FE is hashed, it is hashed into exactly - When a feature vector from BASE_FE is hashed, it is hashed into exactly
get_scales().size() hash bins. Each hash is computed as follows: get_scales().size() hash bins. Each hash is computed as follows:
- first normalize the feature vector - First normalize the feature vector.
- then multiply it by an element of get_scales() - Then multiply it by an element of get_scales().
- then convert the resulting vector to a vector of dlib::int32 - Then convert the resulting vector to a vector of dlib::int32.
- finally, hash the integer vector into a hash bin. - Finally, hash the integer vector into a hash bin.
- The size of the numbers in get_scales() determines how "big" the hash bins are. - The size of the numbers in get_scales() determines how "big" the hash bins are.
A very small scale value would result in all input vectors being hashed into the A very small scale value would result in all input vectors being hashed into the
same bin, while larger scale values would result in only similar vectors same bin, while larger scale values would result in only similar vectors
...@@ -97,22 +96,12 @@ namespace dlib ...@@ -97,22 +96,12 @@ namespace dlib
); );
/*! /*!
requires requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h - image_type == any type that can be supplied to feature_extractor::load()
- pixel_traits<typename image_type::type>::has_alpha == false
ensures ensures
- if (img is large enough to have at least two local features in it) then - Part of the hashing step is to normalize the features produced by BASE_FE.
- #has_image_statistics() == true This function will accumulate image statistics used to perform this normalization.
- This function will accumulate image statistics across multiple calls. Note that it will accumulate across multiple calls. Therefore, it can be
Therefore, it can be beneficial to pass in many images. beneficial to pass in many images.
!*/
bool has_image_statistics (
) const;
/*!
ensures
- Part of the hashing step is to normalize the features produced by
BASE_FE. This function returns true if we have accumulated the necessary
information to perform this normalization and false otherwise.
!*/ !*/
void copy_configuration ( void copy_configuration (
...@@ -145,8 +134,7 @@ namespace dlib ...@@ -145,8 +134,7 @@ namespace dlib
); );
/*! /*!
requires requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h - image_type == any type that can be supplied to feature_extractor::load()
- pixel_traits<typename image_type::type>::has_alpha == false
ensures ensures
- performs BASE_FE.load(img) - performs BASE_FE.load(img)
i.e. does feature extraction. The features can be accessed using i.e. does feature extraction. The features can be accessed using
...@@ -198,11 +186,10 @@ namespace dlib ...@@ -198,11 +186,10 @@ namespace dlib
) const; ) const;
/*! /*!
requires requires
- has_image_statistics() == true
- 0 <= row < nr() - 0 <= row < nr()
- 0 <= col < nc() - 0 <= col < nc()
ensures ensures
- hashes BASE_FE(row,col) and returns resulting indicator vector. - hashes BASE_FE(row,col) and returns the resulting indicator vector.
- Returns a vector V such that: - Returns a vector V such that:
- V.size() == get_scales().size() - V.size() == get_scales().size()
- for all valid i: 0 <= V[i].first < get_num_dimensions() - for all valid i: 0 <= V[i].first < get_num_dimensions()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment