MCPcopy Create free account
hub / github.com/davisking/dlib / bind_image_classes

Function bind_image_classes

tools/python/src/image.cpp:256–742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254// ----------------------------------------------------------------------------------------
255
256void bind_image_classes(py::module& m)
257{
258
259
260
261 py::class_<rgb_pixel>(m, "rgb_pixel")
262 .def(py::init<unsigned char,unsigned char,unsigned char>(), py::arg("red"), py::arg("green"), py::arg("blue"))
263 .def("__str__", &print_rgb_pixel_str)
264 .def("__repr__", &print_rgb_pixel_repr)
265 .def_readwrite("red", &rgb_pixel::red)
266 .def_readwrite("green", &rgb_pixel::green)
267 .def_readwrite("blue", &rgb_pixel::blue);
268
269 const char* docs = "Thresholds img and returns the result. Pixels in img with grayscale values >= partition_pixels(img) \n"
270 "have an output value of 255 and all others have a value of 0.";
271 m.def("threshold_image", &py_threshold_image<unsigned char>, py::arg("img") );
272 m.def("threshold_image", &py_threshold_image<uint16_t>, py::arg("img") );
273 m.def("threshold_image", &py_threshold_image<uint32_t>, py::arg("img") );
274 m.def("threshold_image", &py_threshold_image<float>, py::arg("img") );
275 m.def("threshold_image", &py_threshold_image<double>, py::arg("img") );
276 m.def("threshold_image", &py_threshold_image<rgb_pixel>,docs, py::arg("img") );
277
278 docs = "Thresholds img and returns the result. Pixels in img with grayscale values >= thresh \n"
279 "have an output value of 255 and all others have a value of 0.";
280 m.def("threshold_image", &py_threshold_image2<unsigned char>, py::arg("img"), py::arg("thresh") );
281 m.def("threshold_image", &py_threshold_image2<uint16_t>, py::arg("img"), py::arg("thresh") );
282 m.def("threshold_image", &py_threshold_image2<uint32_t>, py::arg("img"), py::arg("thresh") );
283 m.def("threshold_image", &py_threshold_image2<float>, py::arg("img"), py::arg("thresh") );
284 m.def("threshold_image", &py_threshold_image2<double>, py::arg("img"), py::arg("thresh") );
285 m.def("threshold_image", &py_threshold_image2<rgb_pixel>,docs, py::arg("img"), py::arg("thresh") );
286
287
288 docs =
289"Finds a threshold value that would be reasonable to use with \n\
290threshold_image(img, threshold). It does this by finding the threshold that \n\
291partitions the pixels in img into two groups such that the sum of absolute \n\
292deviations between each pixel and the mean of its group is minimized.";
293 m.def("partition_pixels", &py_partition_pixels<rgb_pixel>, py::arg("img") );
294 m.def("partition_pixels", &py_partition_pixels<unsigned char>, py::arg("img") );
295 m.def("partition_pixels", &py_partition_pixels<uint16_t>, py::arg("img") );
296 m.def("partition_pixels", &py_partition_pixels<uint32_t>, py::arg("img") );
297 m.def("partition_pixels", &py_partition_pixels<float>, py::arg("img") );
298 m.def("partition_pixels", &py_partition_pixels<double>,docs, py::arg("img") );
299
300 docs =
301"This version of partition_pixels() finds multiple partitions rather than just \n\
302one partition. It does this by first partitioning the pixels just as the \n\
303above partition_pixels(img) does. Then it forms a new image with only pixels \n\
304>= that first partition value and recursively partitions this new image. \n\
305However, the recursion is implemented in an efficient way which is faster than \n\
306explicitly forming these images and calling partition_pixels(), but the \n\
307output is the same as if you did. For example, suppose you called \n\
308[t1,t2,t2] = partition_pixels(img,3). Then we would have: \n\
309 - t1 == partition_pixels(img) \n\
310 - t2 == partition_pixels(an image with only pixels with values >= t1 in it) \n\
311 - t3 == partition_pixels(an image with only pixels with values >= t2 in it)" ;
312 m.def("partition_pixels", &py_partition_pixels2<rgb_pixel>, py::arg("img"), py::arg("num_thresholds") );
313 m.def("partition_pixels", &py_partition_pixels2<unsigned char>, py::arg("img"), py::arg("num_thresholds") );

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 14

make_tupleFunction · 0.85
gradient_xMethod · 0.80
gradient_yMethod · 0.80
gradient_xxMethod · 0.80
gradient_xyMethod · 0.80
gradient_yyMethod · 0.80
get_x_filterMethod · 0.80
get_y_filterMethod · 0.80
get_xx_filterMethod · 0.80
get_xy_filterMethod · 0.80
get_yy_filterMethod · 0.80
argClass · 0.50

Tested by

no test coverage detected