35 #include "vtkImageData.h"
54 if (mImage->getModality().contains(
"CT") || mImage->getModality().contains(
"MR"))
55 mImage->setShadingOn(
settings()->value(
"View/shadingOn").value<bool>());
63 double_pair range = this->guessInitialScalarRange();
64 double smin = range.first;
65 double smax = range.second;
68 opacity[fullRange.first - 1] = 0;
69 opacity[fullRange.first] = 255;
70 tf->resetAlpha(opacity);
73 colors[smin] = QColor(Qt::black);
74 colors[smax] = QColor(Qt::white);
75 tf->resetColor(colors);
84 double_pair range = this->guessInitialScalarRange();
86 double smin = range.first;
87 double smax = range.second;
88 double srange = smax - smin;
97 tf->resetAlpha(opacity);
100 colors[smin] = QColor(Qt::black);
101 colors[smax] = QColor(Qt::white);
102 tf->resetColor(colors);
107 bool ImageDefaultTFGenerator::hasValidInitialWindow()
const
109 return mImage->getInitialWindowWidth()>0;
112 double_pair ImageDefaultTFGenerator::guessInitialScalarRange()
const
116 if (this->hasValidInitialWindow())
118 srange = this->getInitialWindowRange();
121 if (!this->hasValidInitialWindow())
123 if (this->isUnsignedChar())
128 if (this->looksLikeBinaryImage())
134 if (mImage->getModality().contains(
"CT"))
136 srange = this->guessCTRange();
138 if (mImage->getModality().contains(
"MR"))
140 srange = this->guessMRRange();
144 srange = this->ensureNonZeroRoundedRange(srange);
148 bool ImageDefaultTFGenerator::isUnsignedChar()
const
150 return mImage->getBaseVtkImageData()->GetScalarType() == VTK_UNSIGNED_CHAR;
153 bool ImageDefaultTFGenerator::looksLikeBinaryImage()
const
164 range.second = std::max(range.second, range.first+1);
168 double_pair ImageDefaultTFGenerator::getFullScalarRange()
const
170 double smin = mImage->getBaseVtkImageData()->GetScalarRange()[0];
171 double smax = mImage->getBaseVtkImageData()->GetScalarRange()[1];
172 return std::make_pair(smin, smax);
175 double_pair ImageDefaultTFGenerator::getInitialWindowRange()
const
177 double smin = mImage->getInitialWindowLevel() - mImage->getInitialWindowWidth()/2;
178 double smax = mImage->getInitialWindowLevel() + mImage->getInitialWindowWidth()/2;
179 return std::make_pair(smin, smax);
182 double_pair ImageDefaultTFGenerator::guessCTRange()
const
188 if (0 >= mImage->getMin())
190 int ct_signed2unsigned = 1024;
191 smin += ct_signed2unsigned;
192 smax += ct_signed2unsigned;
194 return std::make_pair(smin, smax);
197 double_pair ImageDefaultTFGenerator::guessMRRange()
const
200 srange.second *= 0.25;
Handler for the transfer functions used in 3d image volumes.
ImageDefaultTFGenerator(ImagePtr image)
boost::shared_ptr< class Image > ImagePtr
Handling of color and opacity for 2D slices.
std::pair< double, double > double_pair
bool similar(const DoubleBoundingBox3D &a, const DoubleBoundingBox3D &b, double tol)
double roundAwayFromZero(double val)
std::map< int, QColor > ColorMap
boost::shared_ptr< class ImageLUT2D > ImageLUT2DPtr
ImageLUT2DPtr generate2DTFPreset()
Settings * settings()
Shortcut for accessing the settings instance.
std::map< int, int > IntIntMap
ImageTF3DPtr generate3DTFPreset()
boost::shared_ptr< class ImageTF3D > ImageTF3DPtr