mirror of https://github.com/davisking/dlib.git
Added get_histogram() to the python API. Also added more overloads of label_connected_blobs().
This commit is contained in:
parent
5b32723fd2
commit
0249bcb9de
|
@ -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 =
|
||||
|
|
|
@ -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\
|
||||
|
|
Loading…
Reference in New Issue