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
2dcc0253
Commit
2dcc0253
authored
Dec 26, 2011
by
Davis King
Browse files
Added the randomly_sample_image_features() routine.
parent
63e17485
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
0 deletions
+114
-0
dlib/statistics.h
dlib/statistics.h
+1
-0
dlib/statistics/image_feature_sampling.h
dlib/statistics/image_feature_sampling.h
+69
-0
dlib/statistics/image_feature_sampling_abstract.h
dlib/statistics/image_feature_sampling_abstract.h
+44
-0
No files found.
dlib/statistics.h
View file @
2dcc0253
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include "statistics/statistics.h"
#include "statistics/statistics.h"
#include "statistics/dpca.h"
#include "statistics/dpca.h"
#include "statistics/random_subset_selector.h"
#include "statistics/random_subset_selector.h"
#include "statistics/image_feature_sampling.h"
#endif // DLIB_STATISTICs_H_
#endif // DLIB_STATISTICs_H_
...
...
dlib/statistics/image_feature_sampling.h
0 → 100644
View file @
2dcc0253
// Copyright (C) 2011 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_IMAGE_FEATURE_SaMPLING_H__
#define DLIB_IMAGE_FEATURE_SaMPLING_H__
#include "image_feature_sampling_abstract.h"
#include "../statistics.h"
#include "../image_transforms.h"
namespace
dlib
{
// ----------------------------------------------------------------------------------------
template
<
typename
image_array_type
,
typename
feature_extractor_type
,
typename
pyramid_type
>
random_subset_selector
<
typename
feature_extractor_type
::
descriptor_type
>
randomly_sample_image_features
(
const
image_array_type
&
images
,
const
pyramid_type
&
pyr
,
const
feature_extractor_type
&
fe_
,
unsigned
long
num
)
{
feature_extractor_type
fe
;
fe
.
copy_configuration
(
fe_
);
random_subset_selector
<
typename
feature_extractor_type
::
descriptor_type
>
basis
;
basis
.
set_max_size
(
num
);
typedef
typename
image_array_type
::
type
image_type
;
image_type
temp_img
,
temp_img2
;
for
(
unsigned
long
i
=
0
;
i
<
images
.
size
();
++
i
)
{
assign_image
(
temp_img
,
images
[
i
]);
while
(
temp_img
.
nr
()
>
10
&&
temp_img
.
nc
()
>
10
)
{
fe
.
load
(
temp_img
);
for
(
long
r
=
0
;
r
<
fe
.
nr
();
++
r
)
{
for
(
long
c
=
0
;
c
<
fe
.
nc
();
++
c
)
{
if
(
basis
.
next_add_accepts
())
{
basis
.
add
(
fe
(
r
,
c
));
}
else
{
basis
.
add
();
}
}
}
pyr
(
temp_img
,
temp_img2
);
temp_img2
.
swap
(
temp_img
);
}
}
return
basis
;
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_IMAGE_FEATURE_SaMPLING_H__
dlib/statistics/image_feature_sampling_abstract.h
0 → 100644
View file @
2dcc0253
// Copyright (C) 2011 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_IMAGE_FEATURE_SaMPLING_ABSTRACT_H__
#ifdef DLIB_IMAGE_FEATURE_SaMPLING_ABSTRACT_H__
#include "random_subset_selector_abstract.h"
namespace
dlib
{
// ----------------------------------------------------------------------------------------
template
<
typename
image_array_type
,
typename
feature_extractor_type
,
typename
pyramid_type
>
random_subset_selector
<
typename
feature_extractor_type
::
descriptor_type
>
randomly_sample_image_features
(
const
image_array_type
&
images
,
const
pyramid_type
&
pyr
,
const
feature_extractor_type
&
fe
,
unsigned
long
num
);
/*!
requires
- pyramid_type == a type compatible with the image pyramid objects defined
in dlib/image_transforms/image_pyramid_abstract.h
- feature_extractor_type == a local image feature extractor type such as the
dlib::hog_image
- image_array_type == an implementation of dlib/array/array_kernel_abstract.h
and it must contain image objects which can be passed to pyr() and fe.load()
ensures
- creates an image pyramid for each image in images and performs feature
extraction on each pyramid level. Then selects a random subsample of at
most num local feature vectors and returns it.
!*/
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_IMAGE_FEATURE_SaMPLING_ABSTRACT_H__
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