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 if (input->GetOutput()->GetNumberOfScalarComponents() == 3)
89 for (
int i = 0; i < 3; ++i)
92 compWindowLevel->SetInputConnection(input->GetOutputPort());
93 compWindowLevel->SetActiveComponent(i);
94 compWindowLevel->SetLookupTable(lut);
97 compWindowLevel->SetOutputFormatToLuminanceAlpha();
101 compWindowLevel->SetOutputFormatToLuminance();
104 merger->AddInputConnection(compWindowLevel->GetOutputPort());
107 mRedirecter->SetInputConnection(merger->GetOutputPort());
112 windowLevel->SetOutputFormatToRGBA();
113 windowLevel->SetInputConnection(input->GetOutputPort());
114 windowLevel->SetLookupTable(lut);
115 mRedirecter->SetInputConnection(windowLevel->GetOutputPort());
120 mRedirecter->SetInputData(mDummyImage);
123 mRedirecter->Update();
133 return mRedirecter->GetOutput();
144 mMatrixAxes = vtkMatrix4x4Ptr::New();
146 mReslicer = vtkImageReslicePtr::New();
147 mReslicer->SetInterpolationModeToLinear();
148 mReslicer->SetOutputDimensionality(2);
149 mReslicer->SetResliceAxes(mMatrixAxes);
151 mReslicer->AutoCropOutputOn();
155 mRedirecter = vtkImageChangeInformationPtr::New();
164 mReslicer->SetOutputOrigin(origin.data());
165 mReslicer->SetOutputExtent(0, dim[0], 0, dim[1], 0, 0);
169 mReslicer->SetOutputSpacing(spacing.data());
176 disconnect(mSlicer.get(), SIGNAL(transformChanged(
Transform3D)),
this, SLOT(transformChangedSlot()));
181 connect(mSlicer.get(), SIGNAL(transformChanged(
Transform3D)),
this, SLOT(transformChangedSlot()));
186 void SlicedImageProxy::transferFunctionsChangedSlot()
188 mReslicer->SetInputData(mImage->getBaseVtkImageData());
189 mReslicer->SetBackgroundLevel(mImage->getMin());
190 mImageWithLUTProxy->setInput(mRedirecter, mImage->getLookupTable2D()->getOutputLookupTable());
193 void SlicedImageProxy::updateRedirecterSlot()
195 mRedirecter->SetInputConnection(mReslicer->GetOutputPort());
203 disconnect(mImage.get(), SIGNAL(transferFunctionsChanged()),
this, SLOT(transferFunctionsChangedSlot()));
204 disconnect(mImage.get(), SIGNAL(transformChanged()),
this, SLOT(transformChangedSlot()));
205 disconnect(mImage.get(), SIGNAL(vtkImageDataChanged()),
this, SLOT(updateRedirecterSlot()));
212 connect(mImage.get(), SIGNAL(transferFunctionsChanged()),
this, SLOT(transferFunctionsChangedSlot()));
213 connect(mImage.get(), SIGNAL(transformChanged()),
this, SLOT(transformChangedSlot()));
214 connect(mImage.get(), SIGNAL(vtkImageDataChanged()),
this, SLOT(updateRedirecterSlot()));
219 this->updateRedirecterSlot();
220 this->transferFunctionsChangedSlot();
237 return mImageWithLUTProxy->getOutput();
242 return mImageWithLUTProxy->getOutputPort();
247 return mRedirecter->GetOutput();
262 rMs = mSlicer->get_sMr().inv();
266 mMatrixAxes->DeepCopy(M.getVtkMatrix());
269 void SlicedImageProxy::transformChangedSlot()
277 os << indent <<
"mImage: " << (mImage ? mImage->getUid() :
"NULL") << std::endl;
278 os << indent <<
"mSlicer: " << (mSlicer ? mSlicer.get() : 0) << std::endl;
281 mSlicer->printSelf(os, indent.
stepDown());
283 os << indent <<
"mReslicer->GetOutput(): " << mReslicer->GetOutput() << std::endl;
284 os << indent <<
"mReslicer->GetInput() : " << mReslicer->GetInput() << std::endl;
286 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()
Helper class for applying sscLUT2D to an image.
void setInputData(vtkImageDataPtr image, vtkLookupTablePtr lut)