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

Function convert_image

tools/python/src/image.cpp:204–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202
203template <typename T>
204py::array convert_image (
205 const numpy_image<T>& img,
206 const string& dtype
207)
208{
209 if (dtype == "uint8") {numpy_image<uint8_t> out; assign_image(out, img); return out;}
210 if (dtype == "uint16") {numpy_image<uint16_t> out; assign_image(out, img); return out;}
211 if (dtype == "uint32") {numpy_image<uint32_t> out; assign_image(out, img); return out;}
212 if (dtype == "uint64") {numpy_image<uint64_t> out; assign_image(out, img); return out;}
213 if (dtype == "int8") {numpy_image<int8_t> out; assign_image(out, img); return out;}
214 if (dtype == "int16") {numpy_image<int16_t> out; assign_image(out, img); return out;}
215 if (dtype == "int32") {numpy_image<int32_t> out; assign_image(out, img); return out;}
216 if (dtype == "int64") {numpy_image<int64_t> out; assign_image(out, img); return out;}
217 if (dtype == "float32") {numpy_image<float> out; assign_image(out, img); return out;}
218 if (dtype == "float64") {numpy_image<double> out; assign_image(out, img); return out;}
219 if (dtype == "float") {numpy_image<float> out; assign_image(out, img); return out;}
220 if (dtype == "double") {numpy_image<double> out; assign_image(out, img); return out;}
221 if (dtype == "rgb_pixel"){numpy_image<rgb_pixel> out; assign_image(out, img); return out;}
222
223
224 throw dlib::error("convert_image() called with invalid dtype, must be one of these strings: \n"
225 "uint8, int8, uint16, int16, uint32, int32, uint64, int64, float32, float, float64, double, or rgb_pixel");
226}
227
228py::array as_grayscale(
229 const py::array& img

Callers

nothing calls this directly

Calls 2

errorClass · 0.85
assign_imageFunction · 0.50

Tested by

no test coverage detected