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
0aad39c4
Commit
0aad39c4
authored
Mar 21, 2015
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added get_best_hough_point() to the hough_transform object.
parent
f8e91c4f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
166 additions
and
0 deletions
+166
-0
hough_transform.h
dlib/image_transforms/hough_transform.h
+139
-0
hough_transform_abstract.h
dlib/image_transforms/hough_transform_abstract.h
+27
-0
No files found.
dlib/image_transforms/hough_transform.h
View file @
0aad39c4
...
...
@@ -8,6 +8,7 @@
#include "../geometry.h"
#include "../algs.h"
#include "assign_image.h"
#include <limits>
namespace
dlib
{
...
...
@@ -99,6 +100,144 @@ namespace dlib
return
std
::
make_pair
(
p1
,
p2
);
}
template
<
typename
image_type
>
point
get_best_hough_point
(
const
point
&
p
,
const
image_type
&
himg
)
{
DLIB_ASSERT
(
himg
.
nr
()
==
size
()
&&
himg
.
nc
()
==
size
()
&&
rectangle
(
0
,
0
,
size
()
-
1
,
size
()
-
1
).
contains
(
p
)
==
true
,
"
\t
point hough_transform::get_best_hough_point()"
<<
"
\n\t
Invalid arguments given to this function."
<<
"
\n\t
himg.nr(): "
<<
himg
.
nr
()
<<
"
\n\t
himg.nc(): "
<<
himg
.
nc
()
<<
"
\n\t
size(): "
<<
size
()
<<
"
\n\t
p: "
<<
p
);
typedef
typename
image_traits
<
image_type
>::
pixel_type
pixel_type
;
COMPILE_TIME_ASSERT
(
pixel_traits
<
pixel_type
>::
grayscale
==
true
);
pixel_type
best_val
=
std
::
numeric_limits
<
pixel_type
>::
min
();
point
best_point
;
const
long
max_n8
=
(
himg
.
nc
()
/
8
)
*
8
;
const
long
max_n4
=
(
himg
.
nc
()
/
4
)
*
4
;
const
long
r
=
p
.
y
();
const
long
c
=
p
.
x
();
const
int32
*
ysin
=
&
ysin_theta
(
r
,
0
);
const
int32
*
xcos
=
&
xcos_theta
(
c
,
0
);
long
t
=
0
;
while
(
t
<
max_n8
)
{
long
rr0
=
(
*
xcos
++
+
*
ysin
++
)
>>
16
;
long
rr1
=
(
*
xcos
++
+
*
ysin
++
)
>>
16
;
long
rr2
=
(
*
xcos
++
+
*
ysin
++
)
>>
16
;
long
rr3
=
(
*
xcos
++
+
*
ysin
++
)
>>
16
;
long
rr4
=
(
*
xcos
++
+
*
ysin
++
)
>>
16
;
long
rr5
=
(
*
xcos
++
+
*
ysin
++
)
>>
16
;
long
rr6
=
(
*
xcos
++
+
*
ysin
++
)
>>
16
;
long
rr7
=
(
*
xcos
++
+
*
ysin
++
)
>>
16
;
if
(
himg
[
rr0
][
t
++
]
>
best_val
)
{
best_val
=
himg
[
rr0
][
t
-
1
];
best_point
.
x
()
=
t
-
1
;
best_point
.
y
()
=
rr0
;
}
if
(
himg
[
rr1
][
t
++
]
>
best_val
)
{
best_val
=
himg
[
rr1
][
t
-
1
];
best_point
.
x
()
=
t
-
1
;
best_point
.
y
()
=
rr1
;
}
if
(
himg
[
rr2
][
t
++
]
>
best_val
)
{
best_val
=
himg
[
rr2
][
t
-
1
];
best_point
.
x
()
=
t
-
1
;
best_point
.
y
()
=
rr2
;
}
if
(
himg
[
rr3
][
t
++
]
>
best_val
)
{
best_val
=
himg
[
rr3
][
t
-
1
];
best_point
.
x
()
=
t
-
1
;
best_point
.
y
()
=
rr3
;
}
if
(
himg
[
rr4
][
t
++
]
>
best_val
)
{
best_val
=
himg
[
rr4
][
t
-
1
];
best_point
.
x
()
=
t
-
1
;
best_point
.
y
()
=
rr4
;
}
if
(
himg
[
rr5
][
t
++
]
>
best_val
)
{
best_val
=
himg
[
rr5
][
t
-
1
];
best_point
.
x
()
=
t
-
1
;
best_point
.
y
()
=
rr5
;
}
if
(
himg
[
rr6
][
t
++
]
>
best_val
)
{
best_val
=
himg
[
rr6
][
t
-
1
];
best_point
.
x
()
=
t
-
1
;
best_point
.
y
()
=
rr6
;
}
if
(
himg
[
rr7
][
t
++
]
>
best_val
)
{
best_val
=
himg
[
rr7
][
t
-
1
];
best_point
.
x
()
=
t
-
1
;
best_point
.
y
()
=
rr7
;
}
}
while
(
t
<
max_n4
)
{
long
rr0
=
(
*
xcos
++
+
*
ysin
++
)
>>
16
;
long
rr1
=
(
*
xcos
++
+
*
ysin
++
)
>>
16
;
long
rr2
=
(
*
xcos
++
+
*
ysin
++
)
>>
16
;
long
rr3
=
(
*
xcos
++
+
*
ysin
++
)
>>
16
;
if
(
himg
[
rr0
][
t
++
]
>
best_val
)
{
best_val
=
himg
[
rr0
][
t
-
1
];
best_point
.
x
()
=
t
-
1
;
best_point
.
y
()
=
rr0
;
}
if
(
himg
[
rr1
][
t
++
]
>
best_val
)
{
best_val
=
himg
[
rr1
][
t
-
1
];
best_point
.
x
()
=
t
-
1
;
best_point
.
y
()
=
rr1
;
}
if
(
himg
[
rr2
][
t
++
]
>
best_val
)
{
best_val
=
himg
[
rr2
][
t
-
1
];
best_point
.
x
()
=
t
-
1
;
best_point
.
y
()
=
rr2
;
}
if
(
himg
[
rr3
][
t
++
]
>
best_val
)
{
best_val
=
himg
[
rr3
][
t
-
1
];
best_point
.
x
()
=
t
-
1
;
best_point
.
y
()
=
rr3
;
}
}
while
(
t
<
himg
.
nc
())
{
long
rr0
=
(
*
xcos
++
+
*
ysin
++
)
>>
16
;
if
(
himg
[
rr0
][
t
++
]
>
best_val
)
{
best_val
=
himg
[
rr0
][
t
-
1
];
best_point
.
x
()
=
t
-
1
;
best_point
.
y
()
=
rr0
;
}
}
return
best_point
;
}
template
<
typename
in_image_type
,
typename
out_image_type
...
...
dlib/image_transforms/hough_transform_abstract.h
View file @
0aad39c4
...
...
@@ -21,6 +21,10 @@ namespace dlib
contribute correspondingly more to the output of the Hough transform,
allowing stronger edges to create correspondingly stronger line detections
in the final Hough transform.
THREAD SAFETY
It is safe for multiple threads to make concurrent accesses to this object
without synchronization.
!*/
public
:
...
...
@@ -74,6 +78,29 @@ namespace dlib
- The returned points are inside rectangle(0,0,size()-1,size()-1).
!*/
template
<
typename
image_type
>
point
get_best_hough_point
(
const
point
&
p
,
const
image_type
&
himg
);
/*!
requires
- image_type == an image object that implements the interface defined in
dlib/image_processing/generic_image.h and it must contain grayscale pixels.
- himg.nr() == size()
- himg.nc() == size()
- rectangle(0,0,size()-1,size()-1).contains(p) == true
ensures
- This function interprets himg as a Hough image and p as a point in the
original image space. Given this, it finds the maximum scoring line that
passes though p. That is, it checks all the Hough accumulator bins in
himg corresponding to lines though p and returns the location with the
largest score.
- returns a point X such that get_rect(himg).contains(X) == true
!*/
template
<
typename
in_image_type
,
typename
out_image_type
...
...
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