15 #include <vtkImageData.h> 16 #include <vtkImageLuminance.h> 17 #include <vtkImageClip.h> 18 #include <vtkImageAppend.h> 19 #include <vtkMetaImageWriter.h> 20 #include <vtkImageImport.h> 37 mProcessedImage(frames),
48 std::vector<TimedPosition> frameInfo = this->
getFrames();
51 if (inputDims[2] != static_cast<int>(frameInfo.size()))
53 QString msg(
"Mismatch in US input data: inputDims[2] != frameInfo.size() : %1 != %2");
69 CX_ASSERT(index < mProcessedImage.size());
72 unsigned char *inputPointer =
static_cast<unsigned char*
> (mProcessedImage[index]->GetScalarPointer());
78 Eigen::Array3i retval;
79 retval[0] = mProcessedImage[0]->GetDimensions()[0];
80 retval[1] = mProcessedImage[0]->GetDimensions()[1];
81 retval[2] = mProcessedImage.size();
88 retval[2] = retval[0];
121 retval->mName = QFileInfo(inputFrameData->getName()).completeBaseName();
123 retval->resetRemovedFrames();
136 QFileInfo info(inputFilename);
139 QString mhdSingleFile = info.absolutePath()+
"/"+info.completeBaseName()+
".mhd";
141 if (QFileInfo(mhdSingleFile).exists())
146 retval->mName = QFileInfo(mhdSingleFile).completeBaseName();
147 timer.
printElapsedms(QString(
"Loading single %1").arg(inputFilename));
153 retval->mName = QFileInfo(inputFilename).completeBaseName();
155 retval->resetRemovedFrames();
165 retval->mName = name;
166 retval->mImageContainer = images;
167 retval->resetRemovedFrames();
176 return create(name, container);
181 mCropbox(0,0,0,0,0,0), mPurgeInput(true)
213 return Eigen::Array3i(0);
214 Eigen::Array3i retval(image->GetDimensions());
222 Eigen::Array<int, 6, 1> extent(sample->GetExtent());
223 retval[0] = extent[1]-extent[0]+1;
224 retval[1] = extent[3]-extent[2]+1;
238 retval[2] = retval[0];
245 cropbox[4] = -100000;
259 clip->SetInputData(input);
260 clip->SetOutputWholeExtent(cropbox.begin());
265 rawResult->Crop(cropbox.begin());
277 if (input->GetNumberOfScalarComponents() == 1)
280 grayScaleData = input;
292 copy->DeepCopy(outData);
299 if (input->GetScalarSize() > 1)
302 tempImage->resetTransferFunctions();
303 retval = tempImage->get8bitGrayScaleVtkImageData();
344 if (inData->GetNumberOfScalarComponents() != 3)
352 outData->DeepCopy(grayFrame);
359 int* outExt = outData->GetExtent();
365 unsigned char *inPtr =
static_cast<unsigned char*
> (inData->GetScalarPointerForExtent(inData->GetExtent()));
366 unsigned char *outPtr =
static_cast<unsigned char*
> (outData->GetScalarPointerForExtent(outData->GetExtent()));
368 int maxX = outExt[1] - outExt[0];
369 int maxY = outExt[3] - outExt[2];
370 int maxZ = outExt[5] - outExt[4];
372 Eigen::Array<vtkIdType,3,1> inInc;
373 inData->GetContinuousIncrements(inData->GetExtent(), inInc[0], inInc[1], inInc[2]);
376 Eigen::Array<vtkIdType,3,1> outInc;
377 outData->GetContinuousIncrements(outData->GetExtent(), outInc[0], outInc[1], outInc[2]);
382 for (
int z=0; z<=maxZ; z++)
384 for (
int y=0; y<=maxY; y++)
386 for (
int x=0; x<=maxX; x++)
391 if (((*inPtr) == (*(inPtr + 1))) && ((*inPtr) == (*(inPtr + 2))))
401 int metric = (fabs(r-g) + fabs(r-b) + fabs(g-b)) / 3;
427 std::vector<std::vector<vtkImageDataPtr> > raw(angio.size());
429 for (
unsigned i=0; i<raw.size(); ++i)
446 for (
unsigned j=0; j<angio.size(); ++j)
452 raw[j][i] = angioFrame;
456 raw[j][i] = grayFrame;
484 return QFileInfo(
mName).completeBaseName();
506 import->SetImportVoidPointer(source->GetScalarPointer());
507 import->SetDataScalarType(source->GetScalarType());
508 import->SetDataSpacing(source->GetSpacing());
509 import->SetNumberOfScalarComponents(source->GetNumberOfScalarComponents());
510 import->SetWholeExtent(source->GetExtent());
511 import->SetDataExtentToWholeExtent();
518 if (numberOfFrames > 0)
521 if(image && image->GetDataDimension() == 3)
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 ...
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
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.