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
d23084ef
Commit
d23084ef
authored
Feb 11, 2015
by
Davis King
Browse files
Added sub_image() and sub_image_proxy.
parent
aa936bc6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
139 additions
and
0 deletions
+139
-0
dlib/image_transforms/interpolation.h
dlib/image_transforms/interpolation.h
+74
-0
dlib/image_transforms/interpolation_abstract.h
dlib/image_transforms/interpolation_abstract.h
+65
-0
No files found.
dlib/image_transforms/interpolation.h
View file @
d23084ef
...
...
@@ -14,6 +14,80 @@
namespace
dlib
{
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
struct
sub_image_proxy
{
sub_image_proxy
(
T
&
img_
,
const
rectangle
&
rect_
)
:
img
(
img_
),
rect
(
rect_
.
intersect
(
get_rect
(
img_
)))
{}
T
&
img
;
const
rectangle
rect
;
};
template
<
typename
T
>
struct
image_traits
<
sub_image_proxy
<
T
>
>
{
typedef
typename
image_traits
<
T
>::
pixel_type
pixel_type
;
};
template
<
typename
T
>
struct
image_traits
<
const
sub_image_proxy
<
T
>
>
{
typedef
typename
image_traits
<
T
>::
pixel_type
pixel_type
;
};
template
<
typename
T
>
inline
long
num_rows
(
const
sub_image_proxy
<
T
>&
img
)
{
return
img
.
rect
.
height
();
}
template
<
typename
T
>
inline
long
num_columns
(
const
sub_image_proxy
<
T
>&
img
)
{
return
img
.
rect
.
width
();
}
template
<
typename
T
>
inline
void
*
image_data
(
sub_image_proxy
<
T
>&
img
)
{
typedef
typename
image_traits
<
T
>::
pixel_type
pixel_type
;
return
static_cast
<
pixel_type
*>
(
image_data
(
img
.
img
))
+
img
.
rect
.
left
()
+
img
.
rect
.
top
()
*
num_columns
(
img
.
img
);
}
template
<
typename
T
>
inline
const
void
*
image_data
(
const
sub_image_proxy
<
T
>&
img
)
{
typedef
typename
image_traits
<
T
>::
pixel_type
pixel_type
;
return
static_cast
<
const
pixel_type
*>
(
image_data
(
img
.
img
))
+
img
.
rect
.
left
()
+
img
.
rect
.
top
()
*
num_columns
(
img
.
img
);
}
template
<
typename
T
>
inline
long
width_step
(
const
sub_image_proxy
<
T
>&
img
)
{
return
width_step
(
img
.
img
);
}
template
<
typename
image_type
>
sub_image_proxy
<
image_type
>
sub_image
(
image_type
&
img
,
const
rectangle
&
rect
)
{
return
sub_image_proxy
<
image_type
>
(
img
,
rect
);
}
template
<
typename
image_type
>
const
sub_image_proxy
<
const
image_type
>
sub_image
(
const
image_type
&
img
,
const
rectangle
&
rect
)
{
return
sub_image_proxy
<
const
image_type
>
(
img
,
rect
);
}
// ----------------------------------------------------------------------------------------
class
interpolate_nearest_neighbor
...
...
dlib/image_transforms/interpolation_abstract.h
View file @
d23084ef
...
...
@@ -1125,6 +1125,71 @@ namespace dlib
and stores the single output chip into #chip.
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
struct
sub_image_proxy
{
/*!
REQUIREMENTS ON image_type
- image_type == an image object that implements the interface defined in
dlib/image_processing/generic_image.h
WHAT THIS OBJECT REPRESENTS
This is a lightweight image object for referencing a subwindow of an image.
It implements the generic image interface and can therefore be used with
any function that expects a generic image, excepting that you cannot change
the size of a sub_image_proxy.
Note that it only stores a pointer to the image given to its constructor
and therefore does not perform a copy. Moreover, this means that an
instance of this object becomes invalid after the image it references is
destroyed.
!*/
sub_image_proxy
(
T
&
img
,
const
rectangle
&
rect
);
/*!
ensures
- This object is an image that represents the part of img contained within
rect. If rect is larger than img then rect is cropped so that it does
not go outside img.
!*/
};
template
<
typename
image_type
>
sub_image_proxy
<
image_type
>
sub_image
(
image_type
&
img
,
const
rectangle
&
rect
);
/*!
requires
- image_type == an image object that implements the interface defined in
dlib/image_processing/generic_image.h
ensures
- returns sub_image_proxy<image_type>(img,rect)
!*/
template
<
typename
image_type
>
const
sub_image_proxy
<
const
image_type
>
sub_image
(
const
image_type
&
img
,
const
rectangle
&
rect
);
/*!
requires
- image_type == an image object that implements the interface defined in
dlib/image_processing/generic_image.h
ensures
- returns sub_image_proxy<const image_type>(img,rect)
!*/
// ----------------------------------------------------------------------------------------
chip_details
get_face_chip_details
(
...
...
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