14 #include "vtkImageData.h" 33 if (mImage->getModality().contains(
"CT") || mImage->getModality().contains(
"MR"))
34 mImage->setShadingOn(
settings()->value(
"View/shadingOn").value<bool>());
42 double_pair range = this->guessInitialScalarRange();
43 double smin = range.first;
44 double smax = range.second;
47 opacity[fullRange.first - 1] = 0;
48 opacity[fullRange.first] = 255;
49 tf->resetAlpha(opacity);
52 colors[smin] = QColor(Qt::black);
53 colors[smax] = QColor(Qt::white);
54 tf->resetColor(colors);
63 double_pair range = this->guessInitialScalarRange();
65 double smin = range.first;
66 double smax = range.second;
67 double srange = smax - smin;
76 tf->resetAlpha(opacity);
79 colors[smin] = QColor(Qt::black);
80 colors[smax] = QColor(Qt::white);
81 tf->resetColor(colors);
86 bool ImageDefaultTFGenerator::hasValidInitialWindow()
const 88 return mImage->getInitialWindowWidth()>0;
91 double_pair ImageDefaultTFGenerator::guessInitialScalarRange()
const 95 if (this->hasValidInitialWindow())
97 srange = this->getInitialWindowRange();
100 if (!this->hasValidInitialWindow())
102 if (this->isUnsignedChar())
107 if (this->looksLikeBinaryImage())
113 if (mImage->getModality().contains(
"CT"))
115 srange = this->guessCTRange();
117 if (mImage->getModality().contains(
"MR"))
119 srange = this->guessMRRange();
123 srange = this->ensureNonZeroRoundedRange(srange);
127 bool ImageDefaultTFGenerator::isUnsignedChar()
const 129 return mImage->getBaseVtkImageData()->GetScalarType() == VTK_UNSIGNED_CHAR;
132 bool ImageDefaultTFGenerator::looksLikeBinaryImage()
const 143 range.second = std::max(range.second, range.first+1);
147 double_pair ImageDefaultTFGenerator::getFullScalarRange()
const 149 double smin = mImage->getBaseVtkImageData()->GetScalarRange()[0];
150 double smax = mImage->getBaseVtkImageData()->GetScalarRange()[1];
151 return std::make_pair(smin, smax);
154 double_pair ImageDefaultTFGenerator::getInitialWindowRange()
const 156 double smin = mImage->getInitialWindowLevel() - mImage->getInitialWindowWidth()/2;
157 double smax = mImage->getInitialWindowLevel() + mImage->getInitialWindowWidth()/2;
158 return std::make_pair(smin, smax);
161 double_pair ImageDefaultTFGenerator::guessCTRange()
const 173 return std::make_pair(smin, smax);
176 double_pair ImageDefaultTFGenerator::guessMRRange()
const 179 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
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
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
ImageTF3DPtr generate3DTFPreset()
boost::shared_ptr< class ImageTF3D > ImageTF3DPtr
Namespace for all CustusX production code.