14 #include <vtkImageData.h> 15 #include <vtkImageReslice.h> 16 #include <vtkMatrix4x4.h> 18 #include <vtkImageResample.h> 19 #include <vtkImageClip.h> 49 orientator->SetInputData(image->getBaseVtkImageData());
50 orientator->SetInterpolationModeToLinear();
51 orientator->SetOutputDimensionality(3);
52 orientator->SetResliceAxes(qMd.inv().getVtkMatrix());
53 orientator->AutoCropOutputOn();
59 QString uid = image->getUid() +
"_or%1";
60 QString name = image->getName()+
" or%1";
67 oriented->get_rMd_History()->setRegistration(image->get_rMd() * qMd.inv());
68 oriented->mergevtkSettingsIntosscTransform();
79 resampler->SetInputData(image->getBaseVtkImageData());
80 resampler->SetAxisOutputSpacing(0, spacing[0]);
81 resampler->SetAxisOutputSpacing(1, spacing[1]);
82 resampler->SetAxisOutputSpacing(2, spacing[2]);
88 uid = image->getUid() +
"_res%1";
89 name = image->getName()+
" res%1";
103 Vector3D spacing(image->getBaseVtkImageData()->GetSpacing());
104 return resampleImage(dataManager, image, spacing, image->getUid()+
"_copy%1", image->getName()+
" copy%1");
113 clip->SetInputData(input);
114 clip->SetOutputWholeExtent(cropbox.begin());
121 rawResult->ComputeBounds();
131 double* sp = image->getBaseVtkImageData()->GetSpacing();
133 static_cast<int>(bb[0]/sp[0]+0.5), static_cast<int>(bb[1]/sp[0]+0.5),
134 static_cast<int>(bb[2]/sp[1]+0.5), static_cast<int>(bb[3]/sp[1]+0.5),
135 static_cast<int>(bb[4]/sp[2]+0.5), static_cast<int>(bb[5]/sp[2]+0.5));
138 QString uid = image->getUid() +
"_crop%1";
139 QString name = image->getName()+
" crop%1";
143 result->mergevtkSettingsIntosscTransform();
153 QRegExp tsReg(
"[0-9]{8}T[0-9]{6}");
154 if (tsReg.indexIn(text)>0)
165 if ( !imageData ) {
return QImage(); }
167 int width = imageData->GetDimensions()[0];
168 int height = imageData->GetDimensions()[1];
170 QImage image( width, height, QImage::Format_ARGB32 );
171 QRgb *rgbPtr =
reinterpret_cast<QRgb *
>( image.bits() ) + width * ( height - 1 );
172 unsigned char *colorsPtr =
reinterpret_cast<unsigned char *
>( imageData->GetScalarPointer() );
175 for (
int row = 0; row < height; row++ )
177 for (
int col = 0; col < width; col++ )
182 colorsPtr += imageData->GetNumberOfScalarComponents();
198 rgb = QColor(colorsPtr[0], colorsPtr[1], colorsPtr[2], colorsPtr[3] ).rgba();
206 unsigned char threshold = 10;
207 if (colorsPtr[0] < threshold &&
208 colorsPtr[1] < threshold &&
209 colorsPtr[2] < threshold)
217 overlayColor.setAlpha(0);
219 QRgb retval = overlayColor.rgba();
227 if(!image || !patientModel)
235 proxy->setTool(sliceTool);
237 imageSlicer->setSliceProxy(proxy);
238 imageSlicer->setImage(image);
240 proxy->initializeFromPlane(planeType,
false,
false, 1, 0);
244 double screenX = outputDimensions[0]*outputSpacing[0] / 2;
245 double screenY = outputDimensions[1]*outputSpacing[1] / 2;
247 imageSlicer->setOutputFormat(
Vector3D(-screenX,-screenY,0), outputDimensions, outputSpacing);
249 imageSlicer->update();
252 imageSlicer->getOutputPort()->Update();
253 retval->DeepCopy(imageSlicer->getOutput());
257 imageSlicer->getOutputPortWithoutLUT()->Update();
258 retval->DeepCopy(imageSlicer->getOutputWithoutLUT());
vtkSmartPointer< class vtkMatrix4x4 > vtkMatrix4x4Ptr
QRgb modifyOverlayColor(unsigned char *colorsPtr, QColor overlayColor)
ImagePtr resampleImage(PatientModelServicePtr dataManager, ImagePtr image, Transform3D qMd)
static SliceProxyPtr create(PatientModelServicePtr dataManager)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
QRgb convertToQColor(unsigned char *colorsPtr, bool overlay, QColor overlayColor)
vtkImageDataPtr cropImage(vtkImageDataPtr input, IntBoundingBox3D cropbox)
boost::shared_ptr< class Image > ImagePtr
boost::shared_ptr< class SlicedImageProxy > SlicedImageProxyPtr
QString timestampSecondsFormat()
Helper class for slicing an image given a SliceProxy and an image.
vtkImageDataPtr createSlice(ImagePtr image, PLANE_TYPE planeType, Vector3D outputSpacing, Eigen::Array3i outputDimensions, ToolPtr sliceTool, PatientModelServicePtr patientModel, bool applyLUT)
createSlice Creates a 2D slice through a 3D volume. Result slice will be oriented for radiological vi...
bool isDark(unsigned char *colorsPtr)
ImagePtr duplicateImage(PatientModelServicePtr dataManager, ImagePtr image)
ImagePtr createDerivedImage(PatientModelServicePtr dataManager, QString uid, QString name, vtkImageDataPtr raw, ImagePtr parent)
vtkSmartPointer< class vtkImageReslice > vtkImageReslicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
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.
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.
vtkSmartPointer< class vtkImageResample > vtkImageResamplePtr
QImage vtkImageDataToQImage(vtkImageDataPtr imageData, bool overlay, QColor overlayColor)
vtkSmartPointer< class vtkImageClip > vtkImageClipPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
QDateTime extractTimestamp(QString text)
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr