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
0249bcb9
Commit
0249bcb9
authored
May 27, 2018
by
Davis King
Browse files
Added get_histogram() to the python API. Also added more overloads of label_connected_blobs().
parent
5b32723f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
3 deletions
+47
-3
tools/python/src/image.cpp
tools/python/src/image.cpp
+12
-3
tools/python/src/image2.cpp
tools/python/src/image2.cpp
+35
-0
No files found.
tools/python/src/image.cpp
View file @
0249bcb9
...
...
@@ -820,9 +820,18 @@ ensures \n\
- blob labels are contiguous, therefore, the number returned by this function is
the number of blobs in the image (including the background blob).
!*/
m
.
def
(
"label_connected_blobs"
,
py_label_connected_blobs
<
unsigned
char
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"zero_pixels_are_background"
)
=
true
,
py
::
arg
(
"neighborhood_connectivity"
)
=
8
,
py
::
arg
(
"connected_if_both_not_zero"
)
=
false
);
m
.
def
(
"label_connected_blobs"
,
py_label_connected_blobs
<
uint16_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"zero_pixels_are_background"
)
=
true
,
py
::
arg
(
"neighborhood_connectivity"
)
=
8
,
py
::
arg
(
"connected_if_both_not_zero"
)
=
false
);
m
.
def
(
"label_connected_blobs"
,
py_label_connected_blobs
<
uint32_t
>
,
docs
,
py
::
arg
(
"img"
),
py
::
arg
(
"zero_pixels_are_background"
)
=
true
,
py
::
arg
(
"neighborhood_connectivity"
)
=
8
,
py
::
arg
(
"connected_if_both_not_zero"
)
=
false
);
m
.
def
(
"label_connected_blobs"
,
py_label_connected_blobs
<
unsigned
char
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"zero_pixels_are_background"
)
=
true
,
py
::
arg
(
"neighborhood_connectivity"
)
=
8
,
py
::
arg
(
"connected_if_both_not_zero"
)
=
false
);
m
.
def
(
"label_connected_blobs"
,
py_label_connected_blobs
<
uint16_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"zero_pixels_are_background"
)
=
true
,
py
::
arg
(
"neighborhood_connectivity"
)
=
8
,
py
::
arg
(
"connected_if_both_not_zero"
)
=
false
);
m
.
def
(
"label_connected_blobs"
,
py_label_connected_blobs
<
uint32_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"zero_pixels_are_background"
)
=
true
,
py
::
arg
(
"neighborhood_connectivity"
)
=
8
,
py
::
arg
(
"connected_if_both_not_zero"
)
=
false
);
m
.
def
(
"label_connected_blobs"
,
py_label_connected_blobs
<
uint64_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"zero_pixels_are_background"
)
=
true
,
py
::
arg
(
"neighborhood_connectivity"
)
=
8
,
py
::
arg
(
"connected_if_both_not_zero"
)
=
false
);
m
.
def
(
"label_connected_blobs"
,
py_label_connected_blobs
<
float
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"zero_pixels_are_background"
)
=
true
,
py
::
arg
(
"neighborhood_connectivity"
)
=
8
,
py
::
arg
(
"connected_if_both_not_zero"
)
=
false
);
m
.
def
(
"label_connected_blobs"
,
py_label_connected_blobs
<
double
>
,
docs
,
py
::
arg
(
"img"
),
py
::
arg
(
"zero_pixels_are_background"
)
=
true
,
py
::
arg
(
"neighborhood_connectivity"
)
=
8
,
py
::
arg
(
"connected_if_both_not_zero"
)
=
false
);
docs
=
...
...
tools/python/src/image2.cpp
View file @
0249bcb9
...
...
@@ -940,6 +940,20 @@ py::array py_tile_images (
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
py
::
array_t
<
unsigned
long
>
py_get_histogram
(
const
numpy_image
<
T
>&
img
,
size_t
hist_size
)
{
matrix
<
unsigned
long
,
1
>
hist
;
get_histogram
(
img
,
hist
,
hist_size
);
return
numpy_image
<
unsigned
long
>
(
std
::
move
(
hist
)).
squeeze
();
}
// ----------------------------------------------------------------------------------------
void
bind_image_classes2
(
py
::
module
&
m
)
{
...
...
@@ -960,6 +974,27 @@ void bind_image_classes2(py::module& m)
register_extract_image_chip
(
m
);
m
.
def
(
"get_histogram"
,
&
py_get_histogram
<
uint8_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"hist_size"
));
m
.
def
(
"get_histogram"
,
&
py_get_histogram
<
uint16_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"hist_size"
));
m
.
def
(
"get_histogram"
,
&
py_get_histogram
<
uint32_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"hist_size"
));
m
.
def
(
"get_histogram"
,
&
py_get_histogram
<
uint64_t
>
,
py
::
arg
(
"img"
),
py
::
arg
(
"hist_size"
),
"ensures
\n
\
- Returns a numpy array, HIST, that contains a histogram of the pixels in img.
\n
\
In particular, we will have:
\n
\
- len(HIST) == hist_size
\n
\
- for all valid i:
\n
\
- HIST[i] == the number of times a pixel with intensity i appears in img."
/*!
ensures
- Returns a numpy array, HIST, that contains a histogram of the pixels in img.
In particular, we will have:
- len(HIST) == hist_size
- for all valid i:
- HIST[i] == the number of times a pixel with intensity i appears in img.
!*/
);
m
.
def
(
"tile_images"
,
py_tile_images
,
py
::
arg
(
"images"
),
"requires
\n
\
- images is a list of numpy arrays that can be interpreted as images. They
\n
\
...
...
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