36 #include <vtkImageReslice.h> 37 #include <vtkImageMapToWindowLevelColors.h> 38 #include <vtkWindowLevelLookupTable.h> 39 #include <vtkImageData.h> 40 #include <vtkMatrix4x4.h> 41 #include <vtkImageAlgorithm.h> 42 #include <vtkImageChangeInformation.h> 43 #include <vtkImageExtractComponents.h> 44 #include <vtkImageAppendComponents.h> 60 mRedirecter = vtkSmartPointer<vtkImageChangeInformation>::New();
61 mRedirecter->SetInputData(mDummyImage);
72 redirecter->SetInputData(image);
81 if (input->GetOutput())
83 int numScalarComponents = input->GetOutput()->GetNumberOfScalarComponents();
84 if ( numScalarComponents >= 3)
90 for (
int i = 0; i < numScalarComponents; ++i)
93 compWindowLevel->SetInputConnection(input->GetOutputPort());
94 compWindowLevel->SetActiveComponent(i);
95 compWindowLevel->SetLookupTable(lut);
97 if (i==2 && numScalarComponents==3)
99 compWindowLevel->SetOutputFormatToLuminanceAlpha();
103 compWindowLevel->SetOutputFormatToLuminance();
106 merger->AddInputConnection(compWindowLevel->GetOutputPort());
109 mRedirecter->SetInputConnection(merger->GetOutputPort());
114 windowLevel->SetOutputFormatToRGBA();
115 windowLevel->SetInputConnection(input->GetOutputPort());
116 windowLevel->SetLookupTable(lut);
117 mRedirecter->SetInputConnection(windowLevel->GetOutputPort());
122 mRedirecter->SetInputData(mDummyImage);
125 mRedirecter->Update();
135 return mRedirecter->GetOutput();
146 mMatrixAxes = vtkMatrix4x4Ptr::New();
148 mReslicer = vtkImageReslicePtr::New();
149 mReslicer->SetInterpolationModeToLinear();
150 mReslicer->SetOutputDimensionality(2);
151 mReslicer->SetResliceAxes(mMatrixAxes);
153 mReslicer->AutoCropOutputOn();
157 mRedirecter = vtkImageChangeInformationPtr::New();
166 mReslicer->SetOutputOrigin(origin.data());
167 mReslicer->SetOutputExtent(0, dim[0], 0, dim[1], 0, 0);
171 mReslicer->SetOutputSpacing(spacing.data());
178 disconnect(mSlicer.get(), SIGNAL(transformChanged(
Transform3D)),
this, SLOT(transformChangedSlot()));
183 connect(mSlicer.get(), SIGNAL(transformChanged(
Transform3D)),
this, SLOT(transformChangedSlot()));
188 void SlicedImageProxy::transferFunctionsChangedSlot()
190 mReslicer->SetInputData(mImage->getBaseVtkImageData());
191 mReslicer->SetBackgroundLevel(mImage->getMin());
192 mImageWithLUTProxy->setInput(mRedirecter, mImage->getLookupTable2D()->getOutputLookupTable());
195 void SlicedImageProxy::updateRedirecterSlot()
197 mRedirecter->SetInputConnection(mReslicer->GetOutputPort());
205 disconnect(mImage.get(), SIGNAL(transferFunctionsChanged()),
this, SLOT(transferFunctionsChangedSlot()));
206 disconnect(mImage.get(), SIGNAL(transformChanged()),
this, SLOT(transformChangedSlot()));
207 disconnect(mImage.get(), SIGNAL(vtkImageDataChanged()),
this, SLOT(updateRedirecterSlot()));
214 connect(mImage.get(), SIGNAL(transferFunctionsChanged()),
this, SLOT(transferFunctionsChangedSlot()));
215 connect(mImage.get(), SIGNAL(transformChanged()),
this, SLOT(transformChangedSlot()));
216 connect(mImage.get(), SIGNAL(vtkImageDataChanged()),
this, SLOT(updateRedirecterSlot()));
221 this->updateRedirecterSlot();
222 this->transferFunctionsChangedSlot();
239 return mImageWithLUTProxy->getOutput();
244 return mImageWithLUTProxy->getOutputPort();
249 return mRedirecter->GetOutput();
264 rMs = mSlicer->get_sMr().inv();
268 mMatrixAxes->DeepCopy(M.getVtkMatrix());
271 void SlicedImageProxy::transformChangedSlot()
279 os << indent <<
"mImage: " << (mImage ? mImage->getUid() :
"NULL") << std::endl;
280 os << indent <<
"mSlicer: " << (mSlicer ? mSlicer.get() : 0) << std::endl;
283 mSlicer->printSelf(os, indent.
stepDown());
285 os << indent <<
"mReslicer->GetOutput(): " << mReslicer->GetOutput() << std::endl;
286 os << indent <<
"mReslicer->GetInput() : " << mReslicer->GetInput() << std::endl;
288 os << indent <<
"resliceaxes: " << std::endl;
static vtkImageDataPtr createDummyImageData(int axisSize, int maxVoxelValue)
Create a moc object of vtkImageData.
virtual ~SlicedImageProxy()
vtkImageDataPtr getOutput()
output 2D sliced image
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class Image > ImagePtr
void setOutputFormat(Vector3D origin, Eigen::Array3i dim, Vector3D spacing)
vtkSmartPointer< vtkImageChangeInformation > vtkImageChangeInformationPtr
vtkImageAlgorithmPtr getOutputPort()
output 2D sliced image
void printSelf(std::ostream &os, Indent indent)
vtkImageAlgorithmPtr getOutputPortWithoutLUT()
vtkSmartPointer< class vtkImageMapToColors > vtkImageMapToColorsPtr
ImagePtr getImage() const
vtkSmartPointer< class vtkImageAlgorithm > vtkImageAlgorithmPtr
vtkSmartPointer< class vtkImageAppendComponents > vtkImageAppendComponentsPtr
void setInput(vtkImageAlgorithmPtr input, vtkLookupTablePtr lut)
Formatting class for debug printing of the ssc library.
void setSliceProxy(SliceProxyInterfacePtr slicer)
vtkSmartPointer< class vtkLookupTable > vtkLookupTablePtr
void setImage(ImagePtr image)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
vtkImageAlgorithmPtr getOutputPort()
output 2D sliced image
vtkImageDataPtr getOutputWithoutLUT()
vtkImageDataPtr getOutput()
boost::shared_ptr< class SliceProxyInterface > SliceProxyInterfacePtr
virtual ~ApplyLUTToImage2DProxy()
void setInputData(vtkImageDataPtr image, vtkLookupTablePtr lut)
Namespace for all CustusX production code.