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
13d7eaaf
Commit
13d7eaaf
authored
Aug 24, 2011
by
Davis King
Browse files
Cleaned up the interface to draw_line()
parent
32f9ab22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
16 deletions
+53
-16
dlib/image_transforms/draw.h
dlib/image_transforms/draw.h
+24
-6
dlib/image_transforms/draw_abstract.h
dlib/image_transforms/draw_abstract.h
+29
-10
No files found.
dlib/image_transforms/draw.h
View file @
13d7eaaf
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include "draw_abstract.h"
#include "draw_abstract.h"
#include "../algs.h"
#include "../algs.h"
#include "../pixel.h"
#include <cmath>
#include <cmath>
namespace
dlib
namespace
dlib
...
@@ -13,7 +14,8 @@ namespace dlib
...
@@ -13,7 +14,8 @@ namespace dlib
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
image_type
typename
image_type
,
typename
pixel_type
>
>
void
draw_line
(
void
draw_line
(
long
x1
,
long
x1
,
...
@@ -21,7 +23,7 @@ namespace dlib
...
@@ -21,7 +23,7 @@ namespace dlib
long
x2
,
long
x2
,
long
y2
,
long
y2
,
image_type
&
c
,
image_type
&
c
,
typename
image_type
::
type
val
const
pixel_type
&
val
)
)
{
{
if
(
x1
==
x2
)
if
(
x1
==
x2
)
...
@@ -37,7 +39,7 @@ namespace dlib
...
@@ -37,7 +39,7 @@ namespace dlib
if
(
y
<
0
||
y
>=
c
.
nr
())
if
(
y
<
0
||
y
>=
c
.
nr
())
continue
;
continue
;
c
[
y
][
x1
]
=
val
;
assign_pixel
(
c
[
y
][
x1
]
,
val
)
;
}
}
}
}
else
if
(
y1
==
y2
)
else
if
(
y1
==
y2
)
...
@@ -54,7 +56,7 @@ namespace dlib
...
@@ -54,7 +56,7 @@ namespace dlib
if
(
x
<
0
||
x
>=
c
.
nc
())
if
(
x
<
0
||
x
>=
c
.
nc
())
continue
;
continue
;
c
[
y1
][
x
]
=
val
;
assign_pixel
(
c
[
y1
][
x
]
,
val
)
;
}
}
}
}
else
else
...
@@ -97,7 +99,7 @@ namespace dlib
...
@@ -97,7 +99,7 @@ namespace dlib
continue
;
continue
;
c
[
y
][
x
]
=
val
;
assign_pixel
(
c
[
y
][
x
]
,
val
)
;
}
}
}
}
else
else
...
@@ -136,13 +138,29 @@ namespace dlib
...
@@ -136,13 +138,29 @@ namespace dlib
if
(
y
<
0
||
y
>=
c
.
nr
())
if
(
y
<
0
||
y
>=
c
.
nr
())
continue
;
continue
;
c
[
y
][
x
]
=
val
;
assign_pixel
(
c
[
y
][
x
]
,
val
)
;
}
}
}
}
}
}
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
,
typename
pixel_type
>
void
draw_line
(
image_type
&
c
,
const
point
&
p1
,
const
point
&
p2
,
const
pixel_type
&
val
)
{
draw_line
(
p1
.
x
(),
p1
.
y
(),
p2
.
x
(),
p2
.
y
(),
c
,
val
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
...
...
dlib/image_transforms/draw_abstract.h
View file @
13d7eaaf
...
@@ -10,7 +10,32 @@ namespace dlib
...
@@ -10,7 +10,32 @@ namespace dlib
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
typename
image_type
typename
image_type
,
typename
pixel_type
>
void
draw_line
(
image_type
&
c
,
const
point
&
p1
,
const
point
&
p2
,
const
pixel_type
&
val
);
/*!
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- pixel_traits<pixel_type> is defined
ensures
- #img.nr() == img.nr() && #img.nc() == img.nc()
(i.e. the dimensions of the input image are not changed)
- for all valid r and c that are on the line between point p1 and p2:
- performs assign_pixel(img[r][c], val)
(i.e. it draws the line from p1 to p2 onto the image)
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
,
typename
pixel_type
>
>
void
draw_line
(
void
draw_line
(
long
x1
,
long
x1
,
...
@@ -18,18 +43,14 @@ namespace dlib
...
@@ -18,18 +43,14 @@ namespace dlib
long
x2
,
long
x2
,
long
y2
,
long
y2
,
image_type
&
img
,
image_type
&
img
,
typename
image_type
::
type
val
const
pixel_type
&
val
);
);
/*!
/*!
requires
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- pixel_traits<pixel_type> is defined
ensures
ensures
- #img.nr() == img.nr() && #img.nc() == img.nc()
- performs draw_line(img, point(x1,y1), point(x2,y2), val)
(i.e. the dimensions of the input image are not chanaged)
- for all valid r and c that are on the line between point (x1,y1)
and point (x2,y2):
- performs img[r][c] = val
(i.e. it draws the line from (x1,y1) to (x2,y2) onto the image)
!*/
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -50,8 +71,6 @@ namespace dlib
...
@@ -50,8 +71,6 @@ namespace dlib
- fills the area defined by rect in the given image with the given pixel value.
- fills the area defined by rect in the given image with the given pixel value.
!*/
!*/
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
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