36 #include <vtkImageData.h>
37 #include <vtkImageLuminance.h>
38 #include <vtkImageClip.h>
39 #include <vtkImageAppend.h>
40 #include <vtkMetaImageWriter.h>
41 #include <vtkImageImport.h>
57 mProcessedImage(frames),
68 std::vector<TimedPosition> frameInfo = this->
getFrames();
71 if (inputDims[2] != static_cast<int>(frameInfo.size()))
73 QString msg(
"Mismatch in US input data: inputDims[2] != frameInfo.size() : %1 != %2");
89 CX_ASSERT(index < mProcessedImage.size());
92 unsigned char *inputPointer =
static_cast<unsigned char*
> (mProcessedImage[index]->GetScalarPointer());
98 Eigen::Array3i retval;
99 retval[0] = mProcessedImage[0]->GetDimensions()[0];
100 retval[1] = mProcessedImage[0]->GetDimensions()[1];
101 retval[2] = mProcessedImage.size();
108 retval[2] = retval[0];
141 retval->mName = QFileInfo(inputFrameData->getName()).completeBaseName();
143 retval->resetRemovedFrames();
156 QFileInfo info(inputFilename);
159 QString mhdSingleFile = info.absolutePath()+
"/"+info.completeBaseName()+
".mhd";
161 if (QFileInfo(mhdSingleFile).exists())
166 retval->mName = QFileInfo(mhdSingleFile).completeBaseName();
167 timer.
printElapsedms(QString(
"Loading single %1").arg(inputFilename));
173 retval->mName = QFileInfo(inputFilename).completeBaseName();
175 retval->resetRemovedFrames();
185 retval->mName = name;
186 retval->mImageContainer = images;
187 retval->resetRemovedFrames();
196 return create(name, container);
201 mCropbox(0,0,0,0,0,0), mPurgeInput(true)
239 Eigen::Array<int, 6, 1> extent(sample->GetExtent());
240 retval[0] = extent[1]-extent[0]+1;
241 retval[1] = extent[3]-extent[2]+1;
255 retval[2] = retval[0];
262 cropbox[4] = -100000;
276 clip->SetInputData(input);
277 clip->SetOutputWholeExtent(cropbox.begin());
282 rawResult->Crop(cropbox.begin());
294 if (input->GetNumberOfScalarComponents() == 1)
297 grayScaleData = input;
309 copy->DeepCopy(outData);
316 if (input->GetScalarSize() > 1)
319 tempImage->resetTransferFunctions();
320 retval = tempImage->get8bitGrayScaleVtkImageData();
361 if (inData->GetNumberOfScalarComponents() != 3)
369 outData->DeepCopy(grayFrame);
376 int* outExt = outData->GetExtent();
382 unsigned char *inPtr =
static_cast<unsigned char*
> (inData->GetScalarPointerForExtent(inData->GetExtent()));
383 unsigned char *outPtr =
static_cast<unsigned char*
> (outData->GetScalarPointerForExtent(outData->GetExtent()));
385 int maxX = outExt[1] - outExt[0];
386 int maxY = outExt[3] - outExt[2];
387 int maxZ = outExt[5] - outExt[4];
389 Eigen::Array<vtkIdType,3,1> inInc;
390 inData->GetContinuousIncrements(inData->GetExtent(), inInc[0], inInc[1], inInc[2]);
393 Eigen::Array<vtkIdType,3,1> outInc;
394 outData->GetContinuousIncrements(outData->GetExtent(), outInc[0], outInc[1], outInc[2]);
399 for (
int z=0; z<=maxZ; z++)
401 for (
int y=0; y<=maxY; y++)
403 for (
int x=0; x<=maxX; x++)
408 if (((*inPtr) == (*(inPtr + 1))) && ((*inPtr) == (*(inPtr + 2))))
418 int metric = (fabs(r-g) + fabs(r-b) + fabs(g-b)) / 3;
444 std::vector<std::vector<vtkImageDataPtr> > raw(angio.size());
446 for (
unsigned i=0; i<raw.size(); ++i)
463 for (
unsigned j=0; j<angio.size(); ++j)
469 raw[j][i] = angioFrame;
473 raw[j][i] = grayFrame;
501 return QFileInfo(
mName).completeBaseName();
523 import->SetImportVoidPointer(source->GetScalarPointer());
524 import->SetDataScalarType(source->GetScalarType());
525 import->SetDataSpacing(source->GetSpacing());
526 import->SetNumberOfScalarComponents(source->GetNumberOfScalarComponents());
527 import->SetWholeExtent(source->GetExtent());
528 import->SetDataExtentToWholeExtent();
535 if (numberOfFrames > 0)
vtkImageDataPtr cropImageExtent(vtkImageDataPtr input, IntBoundingBox3D cropbox) const
Use only US angio data as input. Removes grayscale from the US data and converts the remaining color ...
vtkSmartPointer< vtkImageAppend > vtkImageAppendPtr
std::vector< std::vector< vtkImageDataPtr > > initializeFrames(std::vector< bool > angio)
cx::ImageDataContainerPtr mImageContainer
#define CX_ASSERT(statement)
void setPurgeInputDataAfterInitialize(bool value)
boost::shared_ptr< class Image > ImagePtr
boost::shared_ptr< class USFrameData > USFrameDataPtr
void printElapsedms(QString text="Elapsed") const
std::vector< int > mReducedToFull
map from indexes in the reduced volume to the full (original) volume.
Eigen::Array3i getDimensions() const
void resetRemovedFrames()
IntBoundingBox3D mCropbox
virtual USFrameDataPtr copy()
Eigen::Vector3i range() const
void reportWarning(QString msg)
vtkImageDataPtr useAngio(vtkImageDataPtr inData, vtkImageDataPtr grayFrame, int frameNum) const
void fillImageImport(vtkImageImportPtr import, int index)
fill import with a single frame
Representation of an integer bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
vtkSmartPointer< class vtkImageClip > vtkImageClipPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
vtkImageDataPtr convertImageDataToGrayScale(vtkImageDataPtr image)
vtkSmartPointer< class vtkImageImport > vtkImageImportPtr
void setCropBox(IntBoundingBox3D mCropbox)
Vector3D getSpacing() const
vtkImageDataPtr to8bitGrayscaleAndEffectuateCropping(vtkImageDataPtr input) const
static USFrameDataPtr create(ImagePtr inputFrameData)
void removeFrame(unsigned int index)
boost::shared_ptr< class ImageDataContainer > ImageDataContainerPtr