14 #include "vtkImageData.h"
31 if ((mImage->getModality() ==
imCT) || (mImage->getModality() ==
imMR))
32 mImage->setShadingOn(
settings()->value(
"View/shadingOn").value<bool>());
40 double_pair range = this->guessInitialScalarRange();
41 double smin = range.first;
42 double smax = range.second;
45 opacity[fullRange.first - 1] = 0;
46 opacity[fullRange.first] = 255;
47 tf->resetAlpha(opacity);
50 colors[smin] = QColor(Qt::black);
51 colors[smax] = QColor(Qt::white);
52 tf->resetColor(colors);
54 if (this->looksLikeBinaryImage())
64 double_pair range = this->guessInitialScalarRange();
66 double smin = range.first;
67 double smax = range.second;
68 double srange = smax - smin;
74 opacity[int(std::lround(smin + 0.5*srange))] = 255;
75 opacity[int(std::lround(smin + 0.3*srange))] = int(std::lround(255.0 * 0.7));
76 opacity[int(std::lround(smin + 0.1*srange))] = 0;
77 tf->resetAlpha(opacity);
80 colors[int(std::lround(smin))] = QColor(Qt::black);
81 colors[int(std::lround(smax))] = QColor(Qt::white);
82 tf->resetColor(colors);
87 bool ImageDefaultTFGenerator::hasValidInitialWindow()
const
89 return mImage->getInitialWindowWidth()>0;
92 double_pair ImageDefaultTFGenerator::guessInitialScalarRange()
const
96 if (this->hasValidInitialWindow())
98 srange = this->getInitialWindowRange();
101 if (!this->hasValidInitialWindow())
103 if (this->isUnsignedChar())
108 if (this->looksLikeBinaryImage())
115 if (mImage->getModality() ==
imCT)
117 srange = this->guessCTRange();
119 if (mImage->getModality() ==
imMR)
121 srange = this->guessMRRange();
125 srange = this->ensureNonZeroRoundedRange(srange);
129 bool ImageDefaultTFGenerator::isUnsignedChar()
const
131 return mImage->getBaseVtkImageData()->GetScalarType() == VTK_UNSIGNED_CHAR;
134 bool ImageDefaultTFGenerator::looksLikeBinaryImage()
const
145 range.second = std::max(range.second, range.first+1);
149 double_pair ImageDefaultTFGenerator::getFullScalarRange()
const
151 double smin = mImage->getBaseVtkImageData()->GetScalarRange()[0];
152 double smax = mImage->getBaseVtkImageData()->GetScalarRange()[1];
153 return std::make_pair(smin, smax);
156 double_pair ImageDefaultTFGenerator::getInitialWindowRange()
const
158 double smin = mImage->getInitialWindowLevel() - mImage->getInitialWindowWidth()/2;
159 double smax = mImage->getInitialWindowLevel() + mImage->getInitialWindowWidth()/2;
160 return std::make_pair(smin, smax);
163 double_pair ImageDefaultTFGenerator::guessCTRange()
const
175 return std::make_pair(smin, smax);
178 double_pair ImageDefaultTFGenerator::guessMRRange()
const
181 srange.second *= 0.25;