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
8c2d87db
Commit
8c2d87db
authored
Sep 04, 2017
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added find_pyramid_down_output_image_size()
parent
9ba4b45f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
0 deletions
+100
-0
image_pyramid.h
dlib/image_transforms/image_pyramid.h
+44
-0
image_pyramid_abstract.h
dlib/image_transforms/image_pyramid_abstract.h
+20
-0
pyramid_down.cpp
dlib/test/pyramid_down.cpp
+36
-0
No files found.
dlib/image_transforms/image_pyramid.h
View file @
8c2d87db
...
...
@@ -977,6 +977,50 @@ namespace dlib
return
(
N
-
1
.
0
)
/
N
;
}
// ----------------------------------------------------------------------------------------
template
<
unsigned
int
N
>
void
find_pyramid_down_output_image_size
(
const
pyramid_down
<
N
>&
pyr
,
long
&
nr
,
long
&
nc
)
{
const
double
rate
=
pyramid_rate
(
pyr
);
nr
=
std
::
floor
(
rate
*
nr
);
nc
=
std
::
floor
(
rate
*
nc
);
}
inline
void
find_pyramid_down_output_image_size
(
const
pyramid_down
<
3
>&
/*pyr*/
,
long
&
nr
,
long
&
nc
)
{
nr
=
2
*
(
nr
-
2
)
/
3
;
nc
=
2
*
(
nc
-
2
)
/
3
;
}
inline
void
find_pyramid_down_output_image_size
(
const
pyramid_down
<
2
>&
/*pyr*/
,
long
&
nr
,
long
&
nc
)
{
nr
=
(
nr
-
3
)
/
2
;
nc
=
(
nc
-
3
)
/
2
;
}
inline
void
find_pyramid_down_output_image_size
(
const
pyramid_down
<
1
>&
/*pyr*/
,
long
&
nr
,
long
&
nc
)
{
nr
=
0
;
nc
=
0
;
}
// ----------------------------------------------------------------------------------------
template
<
...
...
dlib/image_transforms/image_pyramid_abstract.h
View file @
8c2d87db
...
...
@@ -208,6 +208,26 @@ namespace dlib
- returns (N-1.0)/N
!*/
// ----------------------------------------------------------------------------------------
template
<
unsigned
int
N
>
void
find_pyramid_down_output_image_size
(
const
pyramid_down
<
N
>&
pyr
,
long
&
nr
,
long
&
nc
);
/*!
requires
- nr >= 0
- nc >= 0
ensures
- If pyr() were called on an image with nr by nc rows and columns, what would
be the size of the output image? This function finds the size of the output
image and stores it back into #nr and #nc.
!*/
// ----------------------------------------------------------------------------------------
template
<
...
...
dlib/test/pyramid_down.cpp
View file @
8c2d87db
...
...
@@ -278,12 +278,37 @@ void test_pyramid_down_grayscale2()
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
pyramid_down_type
>
void
test_pyr_sizes
()
{
dlib
::
rand
rnd
;
for
(
int
iter
=
0
;
iter
<
20
;
++
iter
)
{
long
nr
=
rnd
.
get_random_32bit_number
()
%
10
+
40
;
long
nc
=
rnd
.
get_random_32bit_number
()
%
10
+
40
;
array2d
<
unsigned
char
>
img
(
nr
,
nc
),
img2
;
assign_all_pixels
(
img
,
0
);
pyramid_down_type
pyr
;
pyr
(
img
,
img2
);
find_pyramid_down_output_image_size
(
pyr
,
nr
,
nc
);
DLIB_TEST
(
img2
.
nr
()
==
nr
);
DLIB_TEST
(
img2
.
nc
()
==
nc
);
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
pyramid_down_type
>
void
test_pyramid_down_small_sizes
()
{
print_spinner
();
// just make sure it doesn't get messed up with small images. This test
// is only really useful if asserts are enabled.
pyramid_down_type
pyr
;
...
...
@@ -378,6 +403,17 @@ void test_pyramid_down_small_sizes()
print_spinner
();
dlog
<<
LINFO
<<
"call test_pyramid_down_grayscale2<pyramid_down<6> >();"
;
test_pyramid_down_grayscale2
<
pyramid_down
<
6
>
>
();
test_pyr_sizes
<
pyramid_down
<
1
>>
();
test_pyr_sizes
<
pyramid_down
<
2
>>
();
test_pyr_sizes
<
pyramid_down
<
3
>>
();
test_pyr_sizes
<
pyramid_down
<
4
>>
();
test_pyr_sizes
<
pyramid_down
<
5
>>
();
test_pyr_sizes
<
pyramid_down
<
6
>>
();
test_pyr_sizes
<
pyramid_down
<
7
>>
();
test_pyr_sizes
<
pyramid_down
<
8
>>
();
test_pyr_sizes
<
pyramid_down
<
28
>>
();
}
}
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