15 #include <vtkImageData.h> 16 #include <vtkImageLuminance.h> 17 #include <vtkImageClip.h> 18 #include <vtkImageAppend.h> 19 #include <vtkMetaImageWriter.h> 20 #include <vtkImageImport.h> 36 mProcessedImage(frames),
47 std::vector<TimedPosition> frameInfo = this->
getFrames();
50 if (inputDims[2] != static_cast<int>(frameInfo.size()))
52 QString msg(
"Mismatch in US input data: inputDims[2] != frameInfo.size() : %1 != %2");
68 CX_ASSERT(index < mProcessedImage.size());
71 unsigned char *inputPointer =
static_cast<unsigned char*
> (mProcessedImage[index]->GetScalarPointer());
77 Eigen::Array3i retval;
78 retval[0] = mProcessedImage[0]->GetDimensions()[0];
79 retval[1] = mProcessedImage[0]->GetDimensions()[1];
80 retval[2] = mProcessedImage.size();
87 retval[2] = retval[0];
120 retval->mName = QFileInfo(inputFrameData->getName()).completeBaseName();
122 retval->resetRemovedFrames();
135 QFileInfo info(inputFilename);
138 QString mhdSingleFile = info.absolutePath()+
"/"+info.completeBaseName()+
".mhd";
140 if (QFileInfo(mhdSingleFile).exists())
145 retval->mName = QFileInfo(mhdSingleFile).completeBaseName();
146 timer.
printElapsedms(QString(
"Loading single %1").arg(inputFilename));
152 retval->mName = QFileInfo(inputFilename).completeBaseName();
154 retval->resetRemovedFrames();
164 retval->mName = name;
165 retval->mImageContainer = images;
166 retval->resetRemovedFrames();
175 return create(name, container);
180 mCropbox(0,0,0,0,0,0), mPurgeInput(true)
218 Eigen::Array<int, 6, 1> extent(sample->GetExtent());
219 retval[0] = extent[1]-extent[0]+1;
220 retval[1] = extent[3]-extent[2]+1;
234 retval[2] = retval[0];
241 cropbox[4] = -100000;
255 clip->SetInputData(input);
256 clip->SetOutputWholeExtent(cropbox.begin());
261 rawResult->Crop(cropbox.begin());
273 if (input->GetNumberOfScalarComponents() == 1)
276 grayScaleData = input;
288 copy->DeepCopy(outData);
295 if (input->GetScalarSize() > 1)
298 tempImage->resetTransferFunctions();
299 retval = tempImage->get8bitGrayScaleVtkImageData();
340 if (inData->GetNumberOfScalarComponents() != 3)
348 outData->DeepCopy(grayFrame);
355 int* outExt = outData->GetExtent();
361 unsigned char *inPtr =
static_cast<unsigned char*
> (inData->GetScalarPointerForExtent(inData->GetExtent()));
362 unsigned char *outPtr =
static_cast<unsigned char*
> (outData->GetScalarPointerForExtent(outData->GetExtent()));
364 int maxX = outExt[1] - outExt[0];
365 int maxY = outExt[3] - outExt[2];
366 int maxZ = outExt[5] - outExt[4];
368 Eigen::Array<vtkIdType,3,1> inInc;
369 inData->GetContinuousIncrements(inData->GetExtent(), inInc[0], inInc[1], inInc[2]);
372 Eigen::Array<vtkIdType,3,1> outInc;
373 outData->GetContinuousIncrements(outData->GetExtent(), outInc[0], outInc[1], outInc[2]);
378 for (
int z=0; z<=maxZ; z++)
380 for (
int y=0; y<=maxY; y++)
382 for (
int x=0; x<=maxX; x++)
387 if (((*inPtr) == (*(inPtr + 1))) && ((*inPtr) == (*(inPtr + 2))))
397 int metric = (fabs(r-g) + fabs(r-b) + fabs(g-b)) / 3;
423 std::vector<std::vector<vtkImageDataPtr> > raw(angio.size());
425 for (
unsigned i=0; i<raw.size(); ++i)
442 for (
unsigned j=0; j<angio.size(); ++j)
448 raw[j][i] = angioFrame;
452 raw[j][i] = grayFrame;
480 return QFileInfo(
mName).completeBaseName();
502 import->SetImportVoidPointer(source->GetScalarPointer());
503 import->SetDataScalarType(source->GetScalarType());
504 import->SetDataSpacing(source->GetSpacing());
505 import->SetNumberOfScalarComponents(source->GetNumberOfScalarComponents());
506 import->SetWholeExtent(source->GetExtent());
507 import->SetDataExtentToWholeExtent();
514 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
Helper class encapsulating a 2S US data set.
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
Namespace for all CustusX production code.