16 #include <vtkMetaImageReader.h> 17 #include <vtkMetaImageWriter.h> 18 #include <vtkImageChangeInformation.h> 19 #include <vtkImageData.h> 35 reader->ReleaseDataFlagOn();
41 zeroer->SetInputConnection(reader->GetOutputPort());
42 zeroer->SetOutputOrigin(0, 0, 0);
44 return zeroer->GetOutput();
59 QString fileType = QFileInfo(filename).suffix();
60 return (fileType.compare(
"mhd", Qt::CaseInsensitive) == 0 || fileType.compare(
"mha", Qt::CaseInsensitive) == 0);
70 return this->
readInto(boost::dynamic_pointer_cast<Image>(data), filename);
84 image->setVtkImageData(raw);
89 image->get_rMd_History()->setRegistration(rMd);
90 image->setModality(customReader->readModality());
91 image->setImageType(customReader->readImageType());
95 double level = customReader->readKey(
"WindowLevel").toDouble(&ok1);
96 double window = customReader->readKey(
"WindowWidth").toDouble(&ok2);
100 image->setInitialWindowLevel(window, level);
101 image->resetTransferFunctions();
111 return std::move(image);
116 std::vector<DataPtr> retval;
127 image->setVtkImageData(raw);
132 image->get_rMd_History()->setRegistration(rMd);
133 image->setModality(customReader->readModality());
134 image->setImageType(customReader->readImageType());
138 double level = customReader->readKey(
"WindowLevel").toDouble(&ok1);
139 double window = customReader->readKey(
"WindowWidth").toDouble(&ok2);
143 image->setInitialWindowLevel(window, level);
144 image->resetTransferFunctions();
147 retval.push_back(image);
157 CX_LOG_ERROR() <<
"MetaImageReader::write: Could not cast data to image";
160 if(!image->getBaseVtkImageData())
162 CX_LOG_ERROR() <<
"MetaImageReader::write: cxImage has no VtkImageData";
166 writer->SetInputData(image->getBaseVtkImageData());
167 writer->SetFileDimensionality(3);
169 QDir().mkpath(QFileInfo(filename).path());
173 writer->SetCompression(
false);
180 customReader->setTransform(image->get_rMd());
181 customReader->setModality(image->getModality());
182 customReader->setImageType(image->getImageType());
183 customReader->setKey(
"WindowLevel",
qstring_cast(image->getInitialWindowLevel()));
184 customReader->setKey(
"WindowWidth",
qstring_cast(image->getInitialWindowWidth()));
185 customReader->setKey(
"Creator", QString(
"CustusX_%1").arg(CustusX_VERSION_STRING));
QString qstring_cast(const T &val)
DataPtr createData(QString type, QString filename, QString name="") const
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class Image > ImagePtr
vtkSmartPointer< vtkImageChangeInformation > vtkImageChangeInformationPtr
cstring_cast_Placeholder cstring_cast(const T &val)
boost::shared_ptr< class Data > DataPtr
vtkSmartPointer< class vtkMetaImageReader > vtkMetaImageReaderPtr
boost::shared_ptr< class CustomMetaImage > CustomMetaImagePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
static QString getTypeName()
vtkSmartPointer< class vtkMetaImageWriter > vtkMetaImageWriterPtr
static bool checkedRead(vtkSmartPointer< vtkAlgorithm > reader, QString filename)
bool canWriteInternal(const QString &type, const QString &filename) const
Namespace for all CustusX production code.