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
98d63d48
Commit
98d63d48
authored
Mar 10, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed the unreasonable requirement that images given to the pyramid
down routines be at least 10 pixels on each side.
parent
1f4694dc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
38 deletions
+93
-38
image_pyramid.h
dlib/image_transforms/image_pyramid.h
+57
-36
image_pyramid_abstract.h
dlib/image_transforms/image_pyramid_abstract.h
+0
-2
pyramid_down.cpp
dlib/test/pyramid_down.cpp
+36
-0
No files found.
dlib/image_transforms/image_pyramid.h
View file @
98d63d48
...
...
@@ -113,11 +113,8 @@ namespace dlib
)
const
{
// make sure requires clause is not broken
DLIB_ASSERT
(
original
.
nr
()
>
10
&&
original
.
nc
()
>
10
&&
is_same_object
(
original
,
down
)
==
false
,
DLIB_ASSERT
(
is_same_object
(
original
,
down
)
==
false
,
"
\t
void pyramid_disable::operator()"
<<
"
\n\t
original.nr(): "
<<
original
.
nr
()
<<
"
\n\t
original.nc(): "
<<
original
.
nc
()
<<
"
\n\t
is_same_object(original, down): "
<<
is_same_object
(
original
,
down
)
<<
"
\n\t
this: "
<<
this
);
...
...
@@ -235,11 +232,8 @@ namespace dlib
)
const
{
// make sure requires clause is not broken
DLIB_ASSERT
(
original
.
nr
()
>
10
&&
original
.
nc
()
>
10
&&
is_same_object
(
original
,
down
)
==
false
,
DLIB_ASSERT
(
is_same_object
(
original
,
down
)
==
false
,
"
\t
void pyramid_down::operator()"
<<
"
\n\t
original.nr(): "
<<
original
.
nr
()
<<
"
\n\t
original.nc(): "
<<
original
.
nc
()
<<
"
\n\t
is_same_object(original, down): "
<<
is_same_object
(
original
,
down
)
<<
"
\n\t
this: "
<<
this
);
...
...
@@ -247,6 +241,12 @@ namespace dlib
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
);
if
(
original
.
nr
()
<=
8
||
original
.
nc
()
<=
8
)
{
down
.
clear
();
return
;
}
typedef
typename
pixel_traits
<
typename
in_image_type
::
type
>::
basic_pixel_type
bp_type
;
typedef
typename
promote
<
bp_type
>::
type
ptype
;
array2d
<
ptype
>
temp_img
;
...
...
@@ -328,11 +328,8 @@ namespace dlib
)
const
{
// make sure requires clause is not broken
DLIB_ASSERT
(
original
.
nr
()
>
10
&&
original
.
nc
()
>
10
&&
is_same_object
(
original
,
down
)
==
false
,
DLIB_ASSERT
(
is_same_object
(
original
,
down
)
==
false
,
"
\t
void pyramid_down::operator()"
<<
"
\n\t
original.nr(): "
<<
original
.
nr
()
<<
"
\n\t
original.nc(): "
<<
original
.
nc
()
<<
"
\n\t
is_same_object(original, down): "
<<
is_same_object
(
original
,
down
)
<<
"
\n\t
this: "
<<
this
);
...
...
@@ -340,6 +337,12 @@ namespace dlib
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
);
if
(
original
.
nr
()
<=
8
||
original
.
nc
()
<=
8
)
{
down
.
clear
();
return
;
}
array2d
<
rgbptype
>
temp_img
;
temp_img
.
set_size
(
original
.
nr
(),
(
original
.
nc
()
-
3
)
/
2
);
down
.
set_size
((
original
.
nr
()
-
3
)
/
2
,
(
original
.
nc
()
-
3
)
/
2
);
...
...
@@ -548,11 +551,8 @@ namespace dlib
)
const
{
// make sure requires clause is not broken
DLIB_ASSERT
(
original
.
nr
()
>
10
&&
original
.
nc
()
>
10
&&
is_same_object
(
original
,
down
)
==
false
,
DLIB_ASSERT
(
is_same_object
(
original
,
down
)
==
false
,
"
\t
void pyramid_down_3_2::operator()"
<<
"
\n\t
original.nr(): "
<<
original
.
nr
()
<<
"
\n\t
original.nc(): "
<<
original
.
nc
()
<<
"
\n\t
is_same_object(original, down): "
<<
is_same_object
(
original
,
down
)
<<
"
\n\t
this: "
<<
this
);
...
...
@@ -560,6 +560,12 @@ namespace dlib
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
);
if
(
original
.
nr
()
<=
8
||
original
.
nc
()
<=
8
)
{
down
.
clear
();
return
;
}
const
long
size_in
=
3
;
const
long
size_out
=
2
;
...
...
@@ -651,11 +657,8 @@ namespace dlib
)
const
{
// make sure requires clause is not broken
DLIB_ASSERT
(
original
.
nr
()
>
10
&&
original
.
nc
()
>
10
&&
is_same_object
(
original
,
down
)
==
false
,
DLIB_ASSERT
(
is_same_object
(
original
,
down
)
==
false
,
"
\t
void pyramid_down_3_2::operator()"
<<
"
\n\t
original.nr(): "
<<
original
.
nr
()
<<
"
\n\t
original.nc(): "
<<
original
.
nc
()
<<
"
\n\t
is_same_object(original, down): "
<<
is_same_object
(
original
,
down
)
<<
"
\n\t
this: "
<<
this
);
...
...
@@ -663,6 +666,12 @@ namespace dlib
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
);
if
(
original
.
nr
()
<=
8
||
original
.
nc
()
<=
8
)
{
down
.
clear
();
return
;
}
const
long
size_in
=
3
;
const
long
size_out
=
2
;
...
...
@@ -865,11 +874,8 @@ namespace dlib
)
const
{
// make sure requires clause is not broken
DLIB_ASSERT
(
original
.
nr
()
>
10
&&
original
.
nc
()
>
10
&&
is_same_object
(
original
,
down
)
==
false
,
DLIB_ASSERT
(
is_same_object
(
original
,
down
)
==
false
,
"
\t
void pyramid_down_4_3::operator()"
<<
"
\n\t
original.nr(): "
<<
original
.
nr
()
<<
"
\n\t
original.nc(): "
<<
original
.
nc
()
<<
"
\n\t
is_same_object(original, down): "
<<
is_same_object
(
original
,
down
)
<<
"
\n\t
this: "
<<
this
);
...
...
@@ -877,6 +883,12 @@ namespace dlib
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
);
if
(
original
.
nr
()
<=
8
||
original
.
nc
()
<=
8
)
{
down
.
clear
();
return
;
}
const
long
size_in
=
4
;
const
long
size_out
=
3
;
...
...
@@ -1047,11 +1059,8 @@ namespace dlib
)
const
{
// make sure requires clause is not broken
DLIB_ASSERT
(
original
.
nr
()
>
10
&&
original
.
nc
()
>
10
&&
is_same_object
(
original
,
down
)
==
false
,
DLIB_ASSERT
(
is_same_object
(
original
,
down
)
==
false
,
"
\t
void pyramid_down_4_3::operator()"
<<
"
\n\t
original.nr(): "
<<
original
.
nr
()
<<
"
\n\t
original.nc(): "
<<
original
.
nc
()
<<
"
\n\t
is_same_object(original, down): "
<<
is_same_object
(
original
,
down
)
<<
"
\n\t
this: "
<<
this
);
...
...
@@ -1059,6 +1068,12 @@ namespace dlib
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
);
if
(
original
.
nr
()
<=
8
||
original
.
nc
()
<=
8
)
{
down
.
clear
();
return
;
}
const
long
size_in
=
4
;
const
long
size_out
=
3
;
...
...
@@ -1411,11 +1426,8 @@ namespace dlib
)
const
{
// make sure requires clause is not broken
DLIB_ASSERT
(
original
.
nr
()
>
10
&&
original
.
nc
()
>
10
&&
is_same_object
(
original
,
down
)
==
false
,
DLIB_ASSERT
(
is_same_object
(
original
,
down
)
==
false
,
"
\t
void pyramid_down_5_4::operator()"
<<
"
\n\t
original.nr(): "
<<
original
.
nr
()
<<
"
\n\t
original.nc(): "
<<
original
.
nc
()
<<
"
\n\t
is_same_object(original, down): "
<<
is_same_object
(
original
,
down
)
<<
"
\n\t
this: "
<<
this
);
...
...
@@ -1423,6 +1435,12 @@ namespace dlib
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
);
if
(
original
.
nr
()
<=
8
||
original
.
nc
()
<=
8
)
{
down
.
clear
();
return
;
}
const
long
size_in
=
5
;
const
long
size_out
=
4
;
...
...
@@ -1735,11 +1753,8 @@ namespace dlib
)
const
{
// make sure requires clause is not broken
DLIB_ASSERT
(
original
.
nr
()
>
10
&&
original
.
nc
()
>
10
&&
is_same_object
(
original
,
down
)
==
false
,
DLIB_ASSERT
(
is_same_object
(
original
,
down
)
==
false
,
"
\t
void pyramid_down_5_4::operator()"
<<
"
\n\t
original.nr(): "
<<
original
.
nr
()
<<
"
\n\t
original.nc(): "
<<
original
.
nc
()
<<
"
\n\t
is_same_object(original, down): "
<<
is_same_object
(
original
,
down
)
<<
"
\n\t
this: "
<<
this
);
...
...
@@ -1747,6 +1762,12 @@ namespace dlib
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
);
if
(
original
.
nr
()
<=
8
||
original
.
nc
()
<=
8
)
{
down
.
clear
();
return
;
}
const
long
size_in
=
5
;
const
long
size_out
=
4
;
...
...
dlib/image_transforms/image_pyramid_abstract.h
View file @
98d63d48
...
...
@@ -37,8 +37,6 @@ namespace dlib
)
const
;
/*!
requires
- original.nr() > 10
- original.nc() > 10
- is_same_object(original, down) == false
- in_image_type == is an implementation of array2d/array2d_kernel_abstract.h
- out_image_type == is an implementation of array2d/array2d_kernel_abstract.h
...
...
dlib/test/pyramid_down.cpp
View file @
98d63d48
...
...
@@ -279,6 +279,31 @@ void test_pyramid_down_grayscale2()
}
// ----------------------------------------------------------------------------------------
template
<
typename
pyramid_down_type
>
void
test_pyramid_down_small_sizes
()
{
// 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
;
for
(
int
size
=
0
;
size
<
20
;
++
size
)
{
array2d
<
unsigned
char
>
img1
(
size
,
size
);
array2d
<
rgb_pixel
>
img2
(
size
,
size
);
array2d
<
unsigned
char
>
out1
;
array2d
<
rgb_pixel
>
out2
;
assign_all_pixels
(
img1
,
0
);
assign_all_pixels
(
img2
,
0
);
pyr
(
img1
,
out1
);
pyr
(
img2
,
out2
);
}
}
// ----------------------------------------------------------------------------------------
...
...
@@ -299,6 +324,17 @@ void test_pyramid_down_grayscale2()
print_spinner
();
test_pyramid_down_rgb
();
print_spinner
();
dlog
<<
LINFO
<<
"call test_pyramid_down_small_sizes<pyramid_down>();"
;
test_pyramid_down_small_sizes
<
pyramid_down
>
();
dlog
<<
LINFO
<<
"call test_pyramid_down_small_sizes<pyramid_down_3_2>();"
;
test_pyramid_down_small_sizes
<
pyramid_down_3_2
>
();
dlog
<<
LINFO
<<
"call test_pyramid_down_small_sizes<pyramid_down_4_3>();"
;
test_pyramid_down_small_sizes
<
pyramid_down_4_3
>
();
dlog
<<
LINFO
<<
"call test_pyramid_down_small_sizes<pyramid_down_5_4>();"
;
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
>
();
print_spinner
();
dlog
<<
LINFO
<<
"call test_pyramid_down_rgb2<pyramid_down>();"
;
...
...
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