| 718 | "); |
| 719 | |
| 720 | static PyObject * |
| 721 | Image_read(PyImage* self, PyObject* args, PyObject* kwargs) |
| 722 | { |
| 723 | auto api = PyUtilApiFunction("s|O!", PyRunTimeErr, __func__); |
| 724 | static char *keywords[] = {"file_name", "scale_factor", NULL}; |
| 725 | char* fileName = NULL; |
| 726 | PyObject* scaleObj = nullptr; |
| 727 | |
| 728 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, api.format, keywords, &fileName, &PyFloat_Type, &scaleObj)) { |
| 729 | return api.argsError(); |
| 730 | } |
| 731 | |
| 732 | self->image_node = ReadFile(std::string(fileName)); |
| 733 | self->image_data = dynamic_cast<mitk::Image*>(self->image_node->GetData()); |
| 734 | |
| 735 | // Process 'scale' argument. |
| 736 | if (scaleObj != nullptr) { |
| 737 | double scale = PyFloat_AsDouble(scaleObj); |
| 738 | if (PyErr_Occurred()) { |
| 739 | return nullptr; |
| 740 | } |
| 741 | |
| 742 | if (scale <= 0.0) { |
| 743 | api.error("The 'scale ' argument must be >= 0.0."); |
| 744 | return nullptr; |
| 745 | } |
| 746 | |
| 747 | ScaleImage(self, scale); |
| 748 | } |
| 749 | |
| 750 | Py_RETURN_NONE; |
| 751 | } |
| 752 | |
| 753 | //--------------------------- |
| 754 | // Image_read_transformation |
nothing calls this directly
no test coverage detected