Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
79f8e146
Commit
79f8e146
authored
Oct 04, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added pyramid_down_generic
parent
2ec475cc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
148 additions
and
0 deletions
+148
-0
image_pyramid.h
dlib/image_transforms/image_pyramid.h
+120
-0
image_pyramid_abstract.h
dlib/image_transforms/image_pyramid_abstract.h
+18
-0
pyramid_down.cpp
dlib/test/pyramid_down.cpp
+10
-0
No files found.
dlib/image_transforms/image_pyramid.h
View file @
79f8e146
...
...
@@ -2332,6 +2332,126 @@ namespace dlib
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
unsigned
int
N
>
class
pyramid_down_generic
:
noncopyable
{
public
:
COMPILE_TIME_ASSERT
(
N
>
1
);
template
<
typename
T
>
vector
<
double
,
2
>
point_down
(
const
vector
<
T
,
2
>&
p
)
const
{
const
double
ratio
=
(
N
-
1
.
0
)
/
N
;
return
p
*
ratio
;
}
template
<
typename
T
>
vector
<
double
,
2
>
point_up
(
const
vector
<
T
,
2
>&
p
)
const
{
const
double
ratio
=
N
/
(
N
-
1
.
0
);
return
p
*
ratio
;
}
// -----------------------------
template
<
typename
T
>
vector
<
double
,
2
>
point_down
(
const
vector
<
T
,
2
>&
p
,
unsigned
int
levels
)
const
{
vector
<
double
,
2
>
temp
=
p
;
for
(
unsigned
int
i
=
0
;
i
<
levels
;
++
i
)
temp
=
point_down
(
temp
);
return
temp
;
}
template
<
typename
T
>
vector
<
double
,
2
>
point_up
(
const
vector
<
T
,
2
>&
p
,
unsigned
int
levels
)
const
{
vector
<
double
,
2
>
temp
=
p
;
for
(
unsigned
int
i
=
0
;
i
<
levels
;
++
i
)
temp
=
point_up
(
temp
);
return
temp
;
}
// -----------------------------
rectangle
rect_up
(
const
rectangle
&
rect
)
const
{
return
rectangle
(
point_up
(
rect
.
tl_corner
()),
point_up
(
rect
.
br_corner
()));
}
rectangle
rect_up
(
const
rectangle
&
rect
,
unsigned
int
levels
)
const
{
return
rectangle
(
point_up
(
rect
.
tl_corner
(),
levels
),
point_up
(
rect
.
br_corner
(),
levels
));
}
// -----------------------------
rectangle
rect_down
(
const
rectangle
&
rect
)
const
{
return
rectangle
(
point_down
(
rect
.
tl_corner
()),
point_down
(
rect
.
br_corner
()));
}
rectangle
rect_down
(
const
rectangle
&
rect
,
unsigned
int
levels
)
const
{
return
rectangle
(
point_down
(
rect
.
tl_corner
(),
levels
),
point_down
(
rect
.
br_corner
(),
levels
));
}
template
<
typename
in_image_type
,
typename
out_image_type
>
void
operator
()
(
const
in_image_type
&
original
,
out_image_type
&
down
)
const
{
// make sure requires clause is not broken
DLIB_ASSERT
(
is_same_object
(
original
,
down
)
==
false
,
"
\t
void pyramid_down_generic::operator()"
<<
"
\n\t
is_same_object(original, down): "
<<
is_same_object
(
original
,
down
)
<<
"
\n\t
this: "
<<
this
);
COMPILE_TIME_ASSERT
(
pixel_traits
<
typename
in_image_type
::
type
>::
has_alpha
==
false
);
COMPILE_TIME_ASSERT
(
pixel_traits
<
typename
out_image_type
::
type
>::
has_alpha
==
false
);
down
.
set_size
(((
N
-
1
)
*
original
.
nr
())
/
N
,
((
N
-
1
)
*
original
.
nc
())
/
N
);
resize_image
(
original
,
down
);
}
};
template
<>
class
pyramid_down_generic
<
2
>
:
public
pyramid_down
{};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
dlib/image_transforms/image_pyramid_abstract.h
View file @
79f8e146
...
...
@@ -188,6 +188,24 @@ namespace dlib
!*/
};
// ----------------------------------------------------------------------------------------
template
<
unsigned
int
N
>
class
pyramid_down_generic
:
noncopyable
{
/*!
REQUIREMENTS ON N
N > 1
WHAT THIS OBJECT REPRESENTS
This is a function object with an interface identical to pyramid_down
(defined at the top of this file) except that it downsamples images at a
ratio of N to N-1 instead of 2 to 1.
!*/
};
// ----------------------------------------------------------------------------------------
class
pyramid_disable
:
noncopyable
...
...
dlib/test/pyramid_down.cpp
View file @
79f8e146
...
...
@@ -335,6 +335,8 @@ void test_pyramid_down_small_sizes()
test_pyramid_down_small_sizes
<
pyramid_down_5_4
>
();
dlog
<<
LINFO
<<
"call test_pyramid_down_small_sizes<pyramid_disable>();"
;
test_pyramid_down_small_sizes
<
pyramid_disable
>
();
dlog
<<
LINFO
<<
"call test_pyramid_down_small_sizes<pyramid_down_generic<3> >();"
;
test_pyramid_down_small_sizes
<
pyramid_down_generic
<
3
>
>
();
print_spinner
();
dlog
<<
LINFO
<<
"call test_pyramid_down_rgb2<pyramid_down>();"
;
...
...
@@ -352,6 +354,10 @@ void test_pyramid_down_small_sizes()
dlog
<<
LINFO
<<
"call test_pyramid_down_rgb2<pyramid_down_5_4>();"
;
test_pyramid_down_rgb2
<
pyramid_down_5_4
>
();
print_spinner
();
dlog
<<
LINFO
<<
"call test_pyramid_down_rgb2<pyramid_down_generic<5> >();"
;
test_pyramid_down_rgb2
<
pyramid_down_generic
<
5
>
>
();
print_spinner
();
dlog
<<
LINFO
<<
"call test_pyramid_down_grayscale2<pyramid_down>();"
;
...
...
@@ -368,6 +374,10 @@ void test_pyramid_down_small_sizes()
print_spinner
();
dlog
<<
LINFO
<<
"call test_pyramid_down_grayscale2<pyramid_down_5_4>();"
;
test_pyramid_down_grayscale2
<
pyramid_down_5_4
>
();
print_spinner
();
dlog
<<
LINFO
<<
"call test_pyramid_down_grayscale2<pyramid_down_generic<6> >();"
;
test_pyramid_down_grayscale2
<
pyramid_down_generic
<
6
>
>
();
}
}
a
;
...
...
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