37 #include "vtkImageData.h"
58 mMaxEnvelopeVoxels = maxVoxels;
68 ImageParameters box = this->createEnvelopeParametersFromImage(mImages[0]);
69 for(
unsigned i = 1; i < mImages.size(); ++i)
70 box = selectParametersWithSmallestExtent(box, this->createEnvelopeParametersFromImage(mImages[i]));
74 ImagePtr retval = this->createEnvelopeFromParameters(box);
85 retval.
setSpacingKeepDim(this->getMinimumSpacingFromAllImages(img->get_rMd().inverse()));
96 ImageParameters ImageEnveloper::selectParametersWithSmallestExtent(ImageParameters a, ImageParameters b)
98 if (a.getVolume() <= b.getVolume())
104 ImageParameters ImageEnveloper::selectParametersWithFewestVoxels(ImageParameters a, ImageParameters b)
106 if (a.getNumVoxels() <= b.getNumVoxels())
112 Eigen::Array3d ImageEnveloper::getMinimumSpacingFromAllImages(
Transform3D qMr)
114 Eigen::Array3d retval;
115 retval = this->getTransformedSpacing(mImages[0]->getSpacing(), qMr * mImages[0]->get_rMd());
116 for (
unsigned i = 1; i < mImages.size(); ++i)
118 Eigen::Array3d current = this->getTransformedSpacing(mImages[i]->getSpacing(), qMr * mImages[i]->get_rMd());
119 retval = retval.min(current);
124 Eigen::Array3d ImageEnveloper::getTransformedSpacing(Eigen::Array3d spacing,
Transform3D qMd)
126 Eigen::Array3d retval;
139 for (
unsigned i = 0; i < 3; ++i)
141 retval[i] = std::max(fabs(sx[i]), fabs(sy[i]));
142 retval[i] = std::max(retval[i], fabs(sz[i]));
148 ImagePtr ImageEnveloper::createEnvelopeFromParameters(ImageParameters box)
150 int maxRange = this->getMaxScalarRange();
154 QString uid = QString(
"envelope_image_%1").arg(box.mParentVolume);
155 ImagePtr retval(
new Image(uid, imageData));
156 retval->get_rMd_History()->setRegistration(box.m_rMd);
157 retval->get_rMd_History()->setParentSpace(box.mParentVolume);
158 retval->setAcquisitionTime(QDateTime::currentDateTime());
159 retval->setModality(
"SC");
164 int ImageEnveloper::getMaxScalarRange()
167 for (
unsigned i=0; i<mImages.size(); ++i)
168 maxRange = std::max<int>(maxRange, mImages[i]->getBaseVtkImageData()->GetScalarRange()[1]);
vtkImageDataPtr generateVtkImageDataUnsignedShort(Eigen::Array3i dim, Vector3D spacing, const unsigned short initValue, int components)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class Image > ImagePtr
Vector3D bottomLeft() const
static ImageEnveloperPtr create()
void limitVoxelsKeepBounds(unsigned long maxVolumeSize)
DoubleBoundingBox3D findEnclosingBoundingBox(std::vector< DataPtr > data, Transform3D qMr)
void setDimKeepBoundsAlignSpacing(Eigen::Array3d bounds)
Transform3D createTransformTranslate(const Vector3D &translation)
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
virtual void setImages(std::vector< ImagePtr > images)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
virtual ImagePtr getEnvelopingImage()
void setMaxEnvelopeVoxels(long maxVoxels)
boost::shared_ptr< class ImageEnveloper > ImageEnveloperPtr
void setSpacingKeepDim(Eigen::Array3d spacing)