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
ee0271b4
"docs/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "39121dfdb80e36620fa62517da020f7a8c12e51a"
Commit
ee0271b4
authored
Mar 17, 2012
by
Davis King
Browse files
Added a resize_image() routine.
parent
bb2dfb1e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
1 deletion
+123
-1
dlib/image_transforms/interpolation.h
dlib/image_transforms/interpolation.h
+71
-1
dlib/image_transforms/interpolation_abstract.h
dlib/image_transforms/interpolation_abstract.h
+52
-0
No files found.
dlib/image_transforms/interpolation.h
View file @
ee0271b4
...
@@ -433,7 +433,6 @@ namespace dlib
...
@@ -433,7 +433,6 @@ namespace dlib
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
image_type
typename
image_type
>
>
...
@@ -453,6 +452,77 @@ namespace dlib
...
@@ -453,6 +452,77 @@ namespace dlib
rotate_image
(
in_img
,
out_img
,
angle
,
interpolate_quadratic
());
rotate_image
(
in_img
,
out_img
,
angle
,
interpolate_quadratic
());
}
}
// ----------------------------------------------------------------------------------------
namespace
impl
{
class
helper_resize_image
{
public:
helper_resize_image
(
double
x_scale_
,
double
y_scale_
)
:
x_scale
(
x_scale_
),
y_scale
(
y_scale_
)
{}
dlib
::
vector
<
double
,
2
>
operator
()
(
const
dlib
::
vector
<
double
,
2
>&
p
)
const
{
return
dlib
::
vector
<
double
,
2
>
(
p
.
x
()
*
x_scale
,
p
.
y
()
*
y_scale
);
}
private:
const
double
x_scale
;
const
double
y_scale
;
};
}
template
<
typename
image_type
,
typename
interpolation_type
>
void
resize_image
(
const
image_type
&
in_img
,
image_type
&
out_img
,
const
interpolation_type
&
interp
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
is_same_object
(
in_img
,
out_img
)
==
false
,
"
\t
void resize_image()"
<<
"
\n\t
Invalid inputs were given to this function."
<<
"
\n\t
is_same_object(in_img, out_img): "
<<
is_same_object
(
in_img
,
out_img
)
);
const
double
x_scale
=
(
in_img
.
nc
()
-
1
)
/
(
double
)
std
::
max
<
long
>
((
out_img
.
nc
()
-
1
),
1
);
const
double
y_scale
=
(
in_img
.
nr
()
-
1
)
/
(
double
)
std
::
max
<
long
>
((
out_img
.
nr
()
-
1
),
1
);
transform_image
(
in_img
,
out_img
,
interp
,
dlib
::
impl
::
helper_resize_image
(
x_scale
,
y_scale
));
}
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
void
resize_image
(
const
image_type
&
in_img
,
image_type
&
out_img
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
is_same_object
(
in_img
,
out_img
)
==
false
,
"
\t
void resize_image()"
<<
"
\n\t
Invalid inputs were given to this function."
<<
"
\n\t
is_same_object(in_img, out_img): "
<<
is_same_object
(
in_img
,
out_img
)
);
resize_image
(
in_img
,
out_img
,
interpolate_quadratic
());
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
...
...
dlib/image_transforms/interpolation_abstract.h
View file @
ee0271b4
...
@@ -316,6 +316,58 @@ namespace dlib
...
@@ -316,6 +316,58 @@ namespace dlib
- uses the interpolate_quadratic object to perform the necessary pixel interpolation.
- uses the interpolate_quadratic object to perform the necessary pixel interpolation.
!*/
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
,
typename
interpolation_type
>
void
resize_image
(
const
image_type
&
in_img
,
image_type
&
out_img
,
const
interpolation_type
&
interp
);
/*!
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- interpolation_type == interpolate_nearest_neighbor, interpolate_bilinear,
interpolate_quadratic, or a type with a compatible interface.
- is_same_object(in_img, out_img) == false
ensures
- #out_img == A copy of in_img which has been stretched so that it
fits exactly into out_img.
- The size of out_img is not modified. I.e.
- #out_img.nr() == out_img.nr()
- #out_img.nc() == out_img.nc()
- uses the supplied interpolation routine interp to perform the necessary
pixel interpolation.
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
void
resize_image
(
const
image_type
&
in_img
,
image_type
&
out_img
);
/*!
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- pixel_traits<typename image_type::type>::has_alpha == false
- is_same_object(in_img, out_img) == false
ensures
- #out_img == A copy of in_img which has been stretched so that it
fits exactly into out_img.
- The size of out_img is not modified. I.e.
- #out_img.nr() == out_img.nr()
- #out_img.nc() == out_img.nc()
- uses the interpolate_quadratic object to perform the necessary pixel
interpolation.
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
...
...
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