38 #include "vtkLookupTable.h"
40 #include "vtkImageMapToColors.h"
41 #include "vtkImageBlend.h"
42 #include "vtkPointData.h"
43 #include "vtkImageShiftScale.h"
45 #include "vtkImageExtractComponents.h"
46 #include "vtkImageAccumulate.h"
48 #include "vtkPiecewiseFunction.h"
53 #include "vtkImageWeightedSum.h"
57 m_MaxThreshold(0),m_MaxImage(0),
58 m_DopplerMode(false), m_DopplerStep(1), m_DopplerTime( 3, 0 ),
59 m_DopplerChannel(0), m_DopplerSize(3)
80 m_MegaImageContainer(iE.m_MegaImageContainer), m_Output(iE.m_Output),
81 m_DopplerMode(iE.m_DopplerMode), m_DopplerStep(iE.m_DopplerStep),
82 m_DopplerTime(iE.m_DopplerTime), m_DopplerChannel(iE.m_DopplerChannel),
83 m_DopplerSize(iE.m_DopplerSize)
108 vtkSmartPointer<vtkLookupTable>
110 createLUT(
const double& iRed,
const double& iGreen,
const double& iBlue,
111 const double& iAlpha)
113 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
114 double* HSV = vtkMath::RGBToHSV(iRed,iGreen,iBlue);
115 lut->SetAlphaRange(0, 1);
116 lut->SetHueRange(HSV[0], HSV[0]);
117 lut->SetSaturationRange(1, 1);
118 lut->SetValueRange(0, 1);
120 double* range =
new double[2];
123 lut->SetRange(range);
134 vtkSmartPointer<vtkLookupTable>
138 GoMegaImageStructureMultiIndexContainer::index<Name>::type::iterator it =
151 vtkSmartPointer<vtkLookupTable>
155 GoMegaImageStructureMultiIndexContainer::index<Visibility>::type::iterator it =
165 vtkSmartPointer<vtkPiecewiseFunction>
169 GoMegaImageStructureMultiIndexContainer::index<Name>::type::iterator it =
174 return it->OpacityTF;
182 std::vector<vtkPiecewiseFunction*>
186 std::vector<vtkPiecewiseFunction*> opacityTFs;
188 typedef GoMegaImageStructureMultiIndexContainer::index<Visibility>::type::iterator
191 IteratorType it0, it1;
192 boost::tuples::tie( it0, it1 ) =
197 opacityTFs.push_back( it0->OpacityTF );
210 GoMegaImageStructureMultiIndexContainer::index<Name>::type::iterator it =
222 setColor(
const std::string& iName, std::vector<double>& iColor)
224 GoMegaImageStructureMultiIndexContainer::index<Name>::type::iterator it =
239 GoMegaImageStructureMultiIndexContainer::index<Name>::type::iterator it =
255 GoMegaImageStructureMultiIndexContainer::index<Name>::type::iterator it =
260 std::vector<int> parameters(3);
261 parameters[0] = it->Gamma;
262 parameters[1] = it->Min;
263 parameters[2] = it->Max;
270 std::map<unsigned int, unsigned int>
274 GoMegaImageStructureMultiIndexContainer::index<Name>::type::iterator it =
284 vtkSmartPointer<vtkImageAccumulate>
288 GoMegaImageStructureMultiIndexContainer::index<Name>::type::iterator it =
293 return it->Histogram;
298 vtkSmartPointer<vtkImageData>
301 vtkSmartPointer<vtkLookupTable> iLUT)
303 vtkSmartPointer<vtkImageMapToColors> coloredImage =
304 vtkSmartPointer<vtkImageMapToColors>::New();
305 coloredImage->SetLookupTable(iLUT);
306 coloredImage->SetInput( iImage );
307 coloredImage->SetOutputFormatToRGB();
308 coloredImage->SetNumberOfThreads(VTK_MAX_THREADS);
309 coloredImage->ReleaseDataFlagOn();
310 coloredImage->Update();
312 return coloredImage->GetOutput();
317 vtkSmartPointer<vtkImageData>
321 GoMegaImageStructureMultiIndexContainer::index<Name>::type::iterator it =
331 vtkSmartPointer<vtkImageData>
335 GoMegaImageStructureMultiIndexContainer::index<Index>::type::iterator it =
346 vtkSmartPointer<vtkImageData>
350 GoMegaImageStructureMultiIndexContainer::index<Visibility>::type::iterator it =
362 std::vector<vtkImageData*>
366 std::vector<vtkImageData*> images;
368 typedef GoMegaImageStructureMultiIndexContainer::index<Visibility>::type::iterator
371 IteratorType it0, it1;
372 boost::tuples::tie( it0, it1 ) =
378 vtkImageData* image = vtkImageData::New();
379 image->DeepCopy( this->
colorImage( it0->Image, it0->LUT ) );
380 images.push_back(image);
389 vtkSmartPointer<vtkImageData>
393 vtkSmartPointer<vtkImageBlend> blendedImage =
394 vtkSmartPointer<vtkImageBlend>::New();
395 blendedImage->RemoveAllInputs();
396 blendedImage->SetBlendModeToCompound();
397 blendedImage->ReleaseDataFlagOn();
398 blendedImage->SetNumberOfThreads(VTK_MAX_THREADS);
400 typedef GoMegaImageStructureMultiIndexContainer::index<Visibility>::type::iterator
403 IteratorType it0, it1;
404 boost::tuples::tie( it0, it1 ) =
409 std::vector< IteratorType > tempVector;
413 tempVector.push_back( it0 );
421 for(
int j = 0; j < N; j++ )
425 vtkSmartPointer<vtkImageData> temp = this->
colorImage(it0->Image, it0->LUT);
426 vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData>::New();
427 image->DeepCopy(temp);
429 blendedImage->AddInput(image);
431 blendedImage->Update();
434 blendedImage->GetOutput()->GetPointData()->GetScalars()->GetRange(rangeR, 0);
436 blendedImage->GetOutput()->GetPointData()->GetScalars()->GetRange(rangeG, 1);
438 blendedImage->GetOutput()->GetPointData()->GetScalars()->GetRange(rangeB, 2);
440 double range = std::max(rangeB[1], std::max(rangeR[1], rangeG[1]));
444 vtkSmartPointer<vtkImageShiftScale> scale =
445 vtkSmartPointer<vtkImageShiftScale>::New();
446 scale->SetInput(blendedImage->GetOutput());
448 scale->SetOutputScalarTypeToUnsignedChar();
449 scale->ReleaseDataFlagOn();
450 scale->SetNumberOfThreads(VTK_MAX_THREADS);
455 return scale->GetOutput();
458 return blendedImage->GetOutput();
620 GoMegaImageStructureMultiIndexContainer::index<Index>::type::iterator it =
636 GoMegaImageStructureMultiIndexContainer::index<Name>::type::iterator it =
651 typedef GoMegaImageStructureMultiIndexContainer::index<Visibility>::type::iterator
654 IteratorType it0, it1;
655 boost::tuples::tie( it0, it1 ) =
658 unsigned int numberOfVisibleChannels( 0 );
663 ++numberOfVisibleChannels;
666 return numberOfVisibleChannels;
673 updatePoints(std::string iName, std::map< unsigned int, unsigned int> iPointsAlpha)
675 GoMegaImageStructureMultiIndexContainer::index<Name>::type::iterator it =
change color of given structure
unsigned int getTimeInterval() const
void setColor(const std::string &iName, std::vector< double > &iColor)
unsigned int m_CurrentTimePoint
unsigned int m_DopplerSize
std::vector< int > getDopplerTime(unsigned int iTime)
unsigned int m_BoundsTime[2]
unsigned int * getBoundsChannel()
unsigned int getDopplerSize()
vtkSmartPointer< vtkLookupTable > getLookuptable() const
get LUT of the first visible channel. Useful is we are in single channel visualization mode...
unsigned int getNumberOfChannels()
void setDopplerMode(const bool &iEnable, const unsigned int &iChannel)
std::map< unsigned int, unsigned int > getAlpha(const std::string &iName) const
get points to update r, g, b and a TFs in TF editor.
vtkSmartPointer< vtkImageData > getImageBW()
get first raw (not colored) visible image
std::string getChannelName(const unsigned int &iIndex)
get name of a channel given its index.
unsigned int getNumberOfVisibleChannels()
get number of visible channels
unsigned int m_DopplerChannel
unsigned int m_BoundsChannel[2]
std::vector< vtkPiecewiseFunction * > getOpacityTransferFunctions()
get vector of visible opacity transfer functions. Useful for the transfer function editor while volum...
unsigned int m_DopplerStep
void setLUTParameters(const std::string &iName, int iGamma, int iMin, int iMax)
std::vector< vtkImageData * > getColoredImages()
get all the visible images colored separately (N images).
std::vector< int > getLUTParameters(const std::string &iName)
GoMegaImageStructureMultiIndexContainer m_MegaImageContainer
void setDopplerStep(unsigned int iStep)
vtkSmartPointer< vtkImageData > colorImage(vtkSmartPointer< vtkImageData > iImage, vtkSmartPointer< vtkLookupTable > iLUT)
void setDopplerSize(int iSize)
unsigned int m_TimeInterval
unsigned int getDopplerChannel()
unsigned int getNumberOfTimePoints()
std::vector< double > getColor(const std::string &iName) const
get color from channel name.
std::vector< int > m_DopplerTime
unsigned int getDopplerStep()
vtkSmartPointer< vtkImageData > getVisibleImages()
get all the -visible- images present in the containerl. Colors the image and combuine them into 1 ima...
vtkSmartPointer< vtkLookupTable > createLUT(const double &iRed, const double &iGreen, const double &iBlue, const double &iAlpha)
create a lookuptable (LUT) given r, g, b, a and range LUT will go from black to the color...
void visibilityChanged(std::string iName, bool iVisibility)
change visibility of one channel given its name.
void updatePoints(std::string iChannel, std::map< unsigned int, unsigned int > iPointsAlpha)
store points from TF editor
vtkSmartPointer< vtkImageAccumulate > getHistogram(const std::string &iName) const
get histogram from 1 channel image
Interface between image reader and vtkImageData.
unsigned int * getBoundsTime()
change visibility of given structure
vtkSmartPointer< vtkPiecewiseFunction > getOpacityTransferFunction(const std::string &iName) const
get opacity from channel name. Useful for the transfer function editor while volume rendering...
virtual ~GoImageProcessor()