15 #include <vtkImageReslice.h>
16 #include <vtkImageMapToWindowLevelColors.h>
17 #include <vtkWindowLevelLookupTable.h>
18 #include <vtkImageData.h>
19 #include <vtkMatrix4x4.h>
20 #include <vtkImageAlgorithm.h>
21 #include <vtkImageChangeInformation.h>
22 #include <vtkImageExtractComponents.h>
23 #include <vtkImageAppendComponents.h>
39 mRedirecter = vtkSmartPointer<vtkImageChangeInformation>::New();
40 mRedirecter->SetInputData(mDummyImage);
51 redirecter->SetInputData(image);
60 if (input->GetOutput())
62 int numScalarComponents = input->GetOutput()->GetNumberOfScalarComponents();
63 if ( numScalarComponents >= 3)
69 for (
int i = 0; i < numScalarComponents; ++i)
72 compWindowLevel->SetInputConnection(input->GetOutputPort());
73 compWindowLevel->SetActiveComponent(i);
74 compWindowLevel->SetLookupTable(lut);
76 if (i==2 && numScalarComponents==3)
78 compWindowLevel->SetOutputFormatToLuminanceAlpha();
82 compWindowLevel->SetOutputFormatToLuminance();
85 merger->AddInputConnection(compWindowLevel->GetOutputPort());
88 mRedirecter->SetInputConnection(merger->GetOutputPort());
93 windowLevel->SetOutputFormatToRGBA();
94 windowLevel->SetInputConnection(input->GetOutputPort());
95 windowLevel->SetLookupTable(lut);
96 mRedirecter->SetInputConnection(windowLevel->GetOutputPort());
101 mRedirecter->SetInputData(mDummyImage);
104 mRedirecter->Update();
114 return mRedirecter->GetOutput();
125 mMatrixAxes = vtkMatrix4x4Ptr::New();
127 mReslicer = vtkImageReslicePtr::New();
128 mReslicer->SetInterpolationModeToLinear();
129 mReslicer->SetOutputDimensionality(2);
130 mReslicer->SetResliceAxes(mMatrixAxes);
132 mReslicer->AutoCropOutputOn();
136 mRedirecter = vtkImageChangeInformationPtr::New();
145 mReslicer->SetOutputOrigin(origin.data());
146 mReslicer->SetOutputExtent(0, dim[0], 0, dim[1], 0, 0);
150 mReslicer->SetOutputSpacing(spacing.data());
157 disconnect(mSlicer.get(), SIGNAL(transformChanged(
Transform3D)),
this, SLOT(transformChangedSlot()));
162 connect(mSlicer.get(), SIGNAL(transformChanged(
Transform3D)),
this, SLOT(transformChangedSlot()));
167 void SlicedImageProxy::transferFunctionsChangedSlot()
169 mReslicer->SetInputData(mImage->getBaseVtkImageData());
170 mReslicer->SetBackgroundLevel(mImage->getMin());
171 mImageWithLUTProxy->setInput(mRedirecter, mImage->getLookupTable2D()->getOutputLookupTable());
174 void SlicedImageProxy::updateRedirecterSlot()
176 mRedirecter->SetInputConnection(mReslicer->GetOutputPort());
184 disconnect(mImage.get(), SIGNAL(transferFunctionsChanged()),
this, SLOT(transferFunctionsChangedSlot()));
185 disconnect(mImage.get(), SIGNAL(transformChanged()),
this, SLOT(transformChangedSlot()));
186 disconnect(mImage.get(), SIGNAL(vtkImageDataChanged()),
this, SLOT(updateRedirecterSlot()));
193 connect(mImage.get(), SIGNAL(transferFunctionsChanged()),
this, SLOT(transferFunctionsChangedSlot()));
194 connect(mImage.get(), SIGNAL(transformChanged()),
this, SLOT(transformChangedSlot()));
195 connect(mImage.get(), SIGNAL(vtkImageDataChanged()),
this, SLOT(updateRedirecterSlot()));
200 this->updateRedirecterSlot();
201 this->transferFunctionsChangedSlot();
218 return mImageWithLUTProxy->getOutput();
223 return mImageWithLUTProxy->getOutputPort();
228 return mRedirecter->GetOutput();
243 rMs = mSlicer->get_sMr().inv();
247 mMatrixAxes->DeepCopy(M.getVtkMatrix());
250 void SlicedImageProxy::transformChangedSlot()
258 os << indent <<
"mImage: " << (mImage ? mImage->getUid() :
"NULL") << std::endl;
259 os << indent <<
"mSlicer: " << (mSlicer ? mSlicer.get() : 0) << std::endl;
262 mSlicer->printSelf(os, indent.
stepDown());
264 os << indent <<
"mReslicer->GetOutput(): " << mReslicer->GetOutput() << std::endl;
265 os << indent <<
"mReslicer->GetInput() : " << mReslicer->GetInput() << std::endl;
267 os << indent <<
"resliceaxes: " << std::endl;