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
13d7eaaf
Commit
13d7eaaf
authored
Aug 24, 2011
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up the interface to draw_line()
parent
32f9ab22
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
16 deletions
+53
-16
draw.h
dlib/image_transforms/draw.h
+24
-6
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 @@
#include "draw_abstract.h"
#include "../algs.h"
#include "../pixel.h"
#include <cmath>
namespace
dlib
...
...
@@ -13,7 +14,8 @@ namespace dlib
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
typename
image_type
,
typename
pixel_type
>
void
draw_line
(
long
x1
,
...
...
@@ -21,7 +23,7 @@ namespace dlib
long
x2
,
long
y2
,
image_type
&
c
,
typename
image_type
::
type
val
const
pixel_type
&
val
)
{
if
(
x1
==
x2
)
...
...
@@ -37,7 +39,7 @@ namespace dlib
if
(
y
<
0
||
y
>=
c
.
nr
())
continue
;
c
[
y
][
x1
]
=
val
;
assign_pixel
(
c
[
y
][
x1
],
val
)
;
}
}
else
if
(
y1
==
y2
)
...
...
@@ -54,7 +56,7 @@ namespace dlib
if
(
x
<
0
||
x
>=
c
.
nc
())
continue
;
c
[
y1
][
x
]
=
val
;
assign_pixel
(
c
[
y1
][
x
]
,
val
)
;
}
}
else
...
...
@@ -97,7 +99,7 @@ namespace dlib
continue
;
c
[
y
][
x
]
=
val
;
assign_pixel
(
c
[
y
][
x
]
,
val
)
;
}
}
else
...
...
@@ -136,13 +138,29 @@ namespace dlib
if
(
y
<
0
||
y
>=
c
.
nr
())
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
<
...
...
dlib/image_transforms/draw_abstract.h
View file @
13d7eaaf
...
...
@@ -10,7 +10,32 @@ namespace dlib
// ----------------------------------------------------------------------------------------
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
(
long
x1
,
...
...
@@ -18,18 +43,14 @@ namespace dlib
long
x2
,
long
y2
,
image_type
&
img
,
typename
image_type
::
type
val
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 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)
- performs draw_line(img, point(x1,y1), point(x2,y2), val)
!*/
// ----------------------------------------------------------------------------------------
...
...
@@ -50,8 +71,6 @@ namespace dlib
- 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