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;
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.