16 #include "vtkImageData.h"
37 mMaxEnvelopeVoxels = maxVoxels;
47 ImageParameters box = this->createEnvelopeParametersFromImage(mImages[0]);
48 for(
unsigned i = 1; i < mImages.size(); ++i)
49 box = selectParametersWithSmallestExtent(box, this->createEnvelopeParametersFromImage(mImages[i]));
53 ImagePtr retval = this->createEnvelopeFromParameters(box);
64 retval.
setSpacingKeepDim(this->getMinimumSpacingFromAllImages(img->get_rMd().inverse()));
75 ImageParameters ImageEnveloper::selectParametersWithSmallestExtent(ImageParameters a, ImageParameters b)
77 if (a.getVolume() <= b.getVolume())
83 ImageParameters ImageEnveloper::selectParametersWithFewestVoxels(ImageParameters a, ImageParameters b)
85 if (a.getNumVoxels() <= b.getNumVoxels())
91 Eigen::Array3d ImageEnveloper::getMinimumSpacingFromAllImages(
Transform3D qMr)
93 Eigen::Array3d retval;
94 retval = this->getTransformedSpacing(mImages[0]->getSpacing(), qMr * mImages[0]->get_rMd());
95 for (
unsigned i = 1; i < mImages.size(); ++i)
97 Eigen::Array3d current = this->getTransformedSpacing(mImages[i]->getSpacing(), qMr * mImages[i]->get_rMd());
98 retval = retval.min(current);
103 Eigen::Array3d ImageEnveloper::getTransformedSpacing(Eigen::Array3d spacing,
Transform3D qMd)
105 Eigen::Array3d retval;
118 for (
unsigned i = 0; i < 3; ++i)
120 retval[i] = std::max(fabs(sx[i]), fabs(sy[i]));
121 retval[i] = std::max(retval[i], fabs(sz[i]));
127 ImagePtr ImageEnveloper::createEnvelopeFromParameters(ImageParameters box)
129 int maxRange = this->getMaxScalarRange();
133 QString uid = QString(
"envelope_image_%1").arg(box.mParentVolume);
134 ImagePtr retval(
new Image(uid, imageData));
135 retval->get_rMd_History()->setRegistration(box.m_rMd);
136 retval->get_rMd_History()->setParentSpace(box.mParentVolume);
137 retval->setAcquisitionTime(QDateTime::currentDateTime());
138 retval->setModality(
imSC);
143 int ImageEnveloper::getMaxScalarRange()
146 for (
unsigned i=0; i<mImages.size(); ++i)
147 maxRange = std::max<int>(maxRange, mImages[i]->getBaseVtkImageData()->GetScalarRange()[1]);