MCPcopy Create free account
hub / github.com/SimVascular/SimVascular / Image_read

Function Image_read

Code/Source/PythonAPI/ImagingImage_PyClass.cxx:720–751  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

718");
719
720static PyObject *
721Image_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

Callers

nothing calls this directly

Calls 5

ScaleImageFunction · 0.85
argsErrorMethod · 0.80
errorMethod · 0.80
ReadFileFunction · 0.70
GetDataMethod · 0.45

Tested by

no test coverage detected