Medical Imaging Interaction Toolkit
2016.11.0
Medical Imaging Interaction Toolkit
|
The LevelWindow class Class to store level/window values. More...
#include <mitkLevelWindow.h>
Public Member Functions | |
LevelWindow (ScalarType level=127.5, ScalarType window=255.0) | |
LevelWindow (const mitk::LevelWindow &levWin) | |
virtual | ~LevelWindow () |
ScalarType | GetLevel () const |
method that returns the level value, i.e. the center of the current grey value interval More... | |
ScalarType | GetWindow () const |
returns the current window size, i.e the range size of the current grey value interval More... | |
ScalarType | GetDefaultLevel () const |
method returns the default level value for the image More... | |
ScalarType | GetDefaultWindow () const |
returns the default window size for the image More... | |
void | ResetDefaultLevelWindow () |
Resets the level and the window value to the default values. More... | |
ScalarType | GetLowerWindowBound () const |
ScalarType | GetUpperWindowBound () const |
void | SetLevelWindow (ScalarType level, ScalarType window, bool expandRangesIfNecessary=true) |
void | SetWindowBounds (ScalarType lowerBound, ScalarType upperBound, bool expandRangesIfNecessary=true) |
void | SetToMaxWindowSize () |
void | SetRangeMinMax (ScalarType min, ScalarType max) |
ScalarType | GetRangeMin () const |
ScalarType | GetRangeMax () const |
ScalarType | GetDefaultLowerBound () const |
ScalarType | GetDefaultUpperBound () const |
void | ResetDefaultRangeMinMax () |
the default min and max range for image will be reset More... | |
ScalarType | GetRange () const |
returns the size of the grey value range More... | |
void | SetDefaultLevelWindow (ScalarType level, ScalarType window) |
void | SetDefaultBoundaries (ScalarType low, ScalarType up) |
void | SetAuto (const Image *image, bool tryPicTags=true, bool guessByCentralSlice=true, unsigned selectedComponent=0) |
sets level/window to optimize the contrast of the given Image More... | |
void | SetToImageRange (const Image *image) |
sets level/window to the min/max greyvalues of the given Image More... | |
void | SetFixed (bool fixed) |
bool | GetFixed () const |
bool | IsFixed () const |
virtual bool | operator== (const LevelWindow &levWin) const |
equality operator implementation that allows to compare two level windows More... | |
virtual bool | operator!= (const LevelWindow &levWin) const |
non equality operator implementation that allows to compare two level windows More... | |
virtual LevelWindow & | operator= (const LevelWindow &levWin) |
implementation necessary because operator made private in itk::Object More... | |
bool | IsFloatingValues () const |
Shows if floating values are accepted. More... | |
void | SetFloatingValues (bool value) |
Sets the floating image value. More... | |
Protected Member Functions | |
void | EnsureConsistency () |
The LevelWindow class Class to store level/window values.
Current min and max value are stored in m_LowerWindowBound and m_UpperWindowBound. The maximum and minimum of valid value range is stored in m_RangeMin and m_RangeMax. m_DefaultLevel amd m_DefaultWindow store the initial Level/Window values for the image. m_DefaultRangeMin and m_DefaultRangeMax store the initial minrange and maxrange for the image.
See documentation of SetAuto for information on how the level window is initialized from an image.
Definition at line 45 of file mitkLevelWindow.h.
mitk::LevelWindow::LevelWindow | ( | mitk::ScalarType | level = 127.5 , |
mitk::ScalarType | window = 255.0 |
||
) |
Definition at line 59 of file mitkLevelWindow.cpp.
References SetDefaultLevelWindow(), and SetLevelWindow().
mitk::LevelWindow::LevelWindow | ( | const mitk::LevelWindow & | levWin | ) |
Definition at line 73 of file mitkLevelWindow.cpp.
|
virtual |
Definition at line 85 of file mitkLevelWindow.cpp.
|
inlineprotected |
confidence tests
if m_LowerWindowBound > m_UpperWindowBound, then the values for m_LowerWindowBound and m_UpperWindowBound will be exchanged
if m_LowerWindowBound < m_RangeMin, m_LowerWindowBound will be set to m_RangeMin. m_UpperWindowBound will be decreased the same as m_LowerWindowBound will be increased, but minimum value for m_UpperWindowBound is also m_RangeMin.
if m_UpperWindowBound > m_RangeMax, m_UpperWindowBound will be set to m_RangeMax. m_LowerWindowBound will be increased the same as m_UpperWindowBound will be decreased, but maximum value for m_LowerWindowBound is also m_RangeMax.
Definition at line 24 of file mitkLevelWindow.cpp.
References m_LowerWindowBound, m_RangeMax, m_RangeMin, m_UpperWindowBound, max(), min(), and swap().
mitk::ScalarType mitk::LevelWindow::GetDefaultLevel | ( | ) | const |
method returns the default level value for the image
Definition at line 99 of file mitkLevelWindow.cpp.
mitk::ScalarType mitk::LevelWindow::GetDefaultLowerBound | ( | ) | const |
Get the default range minimum value
Definition at line 214 of file mitkLevelWindow.cpp.
Referenced by operator=().
mitk::ScalarType mitk::LevelWindow::GetDefaultUpperBound | ( | ) | const |
Get the default range maximum value
Definition at line 209 of file mitkLevelWindow.cpp.
Referenced by operator=().
mitk::ScalarType mitk::LevelWindow::GetDefaultWindow | ( | ) | const |
returns the default window size for the image
Definition at line 104 of file mitkLevelWindow.cpp.
bool mitk::LevelWindow::GetFixed | ( | ) | const |
Returns whether the level window settings are fixed (
Definition at line 447 of file mitkLevelWindow.cpp.
Referenced by operator=(), and QmitkLevelWindowWidgetContextMenu::setFixed().
mitk::ScalarType mitk::LevelWindow::GetLevel | ( | ) | const |
method that returns the level value, i.e. the center of the current grey value interval
Definition at line 89 of file mitkLevelWindow.cpp.
Referenced by QmitkLevelWindowWidgetContextMenu::addPreset(), mitk::DisplayInteractor::AdjustLevelWindow(), QmitkLevelWindowWidgetContextMenu::changeScaleRange(), FLmitkComfortWidget::handle(), mitkLevelWindowTest(), QmlMitkSliderLevelWindowItem::mouseMoveEvent(), QmitkSliderLevelWindowWidget::mouseMoveEvent(), resetLevelWindow(), QmitkLevelWindowWidgetContextMenu::setDefaultScaleRange(), QmlMitkSliderLevelWindowItem::setLevel(), QmlMitkSliderLevelWindowItem::setWindow(), and QmitkLineEditLevelWindowWidget::SetWindowValue().
mitk::ScalarType mitk::LevelWindow::GetLowerWindowBound | ( | ) | const |
Returns the minimum Value of the window
Definition at line 114 of file mitkLevelWindow.cpp.
Referenced by mitk::SurfaceVtkMapper3D::ApplyAllProperties(), mitk::SurfaceVtkMapper2D::ApplyAllProperties(), mitk::RegEvaluationMapper2D::ApplyLevelWindow(), mitk::DoseImageVtkMapper2D::ApplyLevelWindow(), mitk::ImageVtkMapper2D::ApplyLevelWindow(), mitkLevelWindowTest(), operator=(), QmitkSliderLevelWindowWidget::update(), and QmlMitkSliderLevelWindowItem::update().
mitk::ScalarType mitk::LevelWindow::GetRange | ( | ) | const |
returns the size of the grey value range
!
Definition at line 204 of file mitkLevelWindow.cpp.
Referenced by mitkLevelWindowTest(), QmlMitkSliderLevelWindowItem::mouseMoveEvent(), QmitkSliderLevelWindowWidget::mouseMoveEvent(), QmlMitkSliderLevelWindowItem::paint(), QmitkSliderLevelWindowWidget::paintEvent(), QmitkSliderLevelWindowWidget::update(), and QmlMitkSliderLevelWindowItem::update().
mitk::ScalarType mitk::LevelWindow::GetRangeMax | ( | ) | const |
Get the range maximum value
Definition at line 199 of file mitkLevelWindow.cpp.
Referenced by QmitkLevelWindowWidgetContextMenu::changeScaleRange(), QmlMitkSliderLevelWindowItem::mouseMoveEvent(), QmitkSliderLevelWindowWidget::mouseMoveEvent(), operator=(), QmlMitkSliderLevelWindowItem::paint(), QmitkSliderLevelWindowWidget::paintEvent(), resetLevelWindow(), and QmitkLevelWindowWidgetContextMenu::setPreset().
mitk::ScalarType mitk::LevelWindow::GetRangeMin | ( | ) | const |
Get the range minimum value
Definition at line 194 of file mitkLevelWindow.cpp.
Referenced by QmitkLevelWindowWidgetContextMenu::changeScaleRange(), QmlMitkSliderLevelWindowItem::mouseMoveEvent(), QmitkSliderLevelWindowWidget::mouseMoveEvent(), operator=(), QmlMitkSliderLevelWindowItem::paint(), QmitkSliderLevelWindowWidget::paintEvent(), resetLevelWindow(), QmitkLevelWindowWidgetContextMenu::setPreset(), QmitkSliderLevelWindowWidget::update(), and QmlMitkSliderLevelWindowItem::update().
mitk::ScalarType mitk::LevelWindow::GetUpperWindowBound | ( | ) | const |
Returns the upper window bound value of the window
Definition at line 119 of file mitkLevelWindow.cpp.
Referenced by mitk::SurfaceVtkMapper3D::ApplyAllProperties(), mitk::SurfaceVtkMapper2D::ApplyAllProperties(), mitk::RegEvaluationMapper2D::ApplyLevelWindow(), mitk::DoseImageVtkMapper2D::ApplyLevelWindow(), mitk::ImageVtkMapper2D::ApplyLevelWindow(), mitkLevelWindowTest(), operator=(), QmitkSliderLevelWindowWidget::update(), and QmlMitkSliderLevelWindowItem::update().
mitk::ScalarType mitk::LevelWindow::GetWindow | ( | ) | const |
returns the current window size, i.e the range size of the current grey value interval
Definition at line 94 of file mitkLevelWindow.cpp.
Referenced by QmitkLevelWindowWidgetContextMenu::addPreset(), mitk::DisplayInteractor::AdjustLevelWindow(), QmitkLevelWindowWidgetContextMenu::changeScaleRange(), FLmitkComfortWidget::handle(), mitkLevelWindowTest(), QmlMitkSliderLevelWindowItem::mouseMoveEvent(), QmitkSliderLevelWindowWidget::mouseMoveEvent(), mitk::RegionGrowingTool::OnMousePressedOutside(), resetLevelWindow(), QmitkLevelWindowWidgetContextMenu::setDefaultScaleRange(), QmlMitkSliderLevelWindowItem::setLevel(), QmitkLineEditLevelWindowWidget::SetLevelValue(), QmlMitkSliderLevelWindowItem::setWindow(), QmitkSliderLevelWindowWidget::update(), and QmlMitkSliderLevelWindowItem::update().
bool mitk::LevelWindow::IsFixed | ( | ) | const |
Returns whether the level window settings are fixed (
Definition at line 452 of file mitkLevelWindow.cpp.
Referenced by QmitkLevelWindowWidgetContextMenu::getContextMenu(), QmlMitkSliderLevelWindowItem::mouseMoveEvent(), QmitkSliderLevelWindowWidget::mouseMoveEvent(), QmlMitkSliderLevelWindowItem::mousePressEvent(), QmitkSliderLevelWindowWidget::mousePressEvent(), QmlMitkSliderLevelWindowItem::mouseReleaseEvent(), QmitkSliderLevelWindowWidget::mouseReleaseEvent(), and operator==().
bool mitk::LevelWindow::IsFloatingValues | ( | ) | const |
Shows if floating values are accepted.
Definition at line 457 of file mitkLevelWindow.cpp.
Referenced by operator=(), and operator==().
|
virtual |
non equality operator implementation that allows to compare two level windows
Definition at line 478 of file mitkLevelWindow.cpp.
|
virtual |
implementation necessary because operator made private in itk::Object
Definition at line 483 of file mitkLevelWindow.cpp.
References GetDefaultLowerBound(), GetDefaultUpperBound(), GetFixed(), GetLowerWindowBound(), GetRangeMax(), GetRangeMin(), GetUpperWindowBound(), and IsFloatingValues().
|
virtual |
equality operator implementation that allows to compare two level windows
Definition at line 467 of file mitkLevelWindow.cpp.
References mitk::Equal(), IsFixed(), IsFloatingValues(), m_DefaultLowerBound, m_DefaultUpperBound, m_LowerWindowBound, m_RangeMax, m_RangeMin, m_UpperWindowBound, and mitk::sqrteps.
void mitk::LevelWindow::ResetDefaultLevelWindow | ( | ) |
Resets the level and the window value to the default values.
Definition at line 109 of file mitkLevelWindow.cpp.
Referenced by QmitkLevelWindowWidgetContextMenu::setDefaultLevelWindow().
void mitk::LevelWindow::ResetDefaultRangeMinMax | ( | ) |
the default min and max range for image will be reset
Definition at line 219 of file mitkLevelWindow.cpp.
Referenced by QmitkLevelWindowWidgetContextMenu::setDefaultScaleRange().
void mitk::LevelWindow::SetAuto | ( | const Image * | image, |
bool | tryPicTags = true , |
||
bool | guessByCentralSlice = true , |
||
unsigned | selectedComponent = 0 |
||
) |
sets level/window to optimize the contrast of the given Image
!
This method initializes a mitk::LevelWindow from an mitk::Image. The algorithm is as follows:
Default to taking the central image slice for quick analysis.
Compute the smallest (minValue), second smallest (min2ndValue), second largest (max2ndValue), and largest (maxValue) data value by traversing the pixel values only once. In the same scan it also computes the count of minValue values and maxValue values. After that a basic histogram with specific information about the extrems is complete.
If minValue == maxValue, the center slice is uniform and the above scan is repeated for the complete image, not just one slice
Next, special cases of images with only 1, 2 or 3 distinct data values have hand assigned level window ranges.
Next the level window is set relative to the inner range IR = lengthOf([min2ndValue, max2ndValue])
For count(minValue) > 20% the smallest values are frequent and should be distinct from the min2ndValue and larger values (minValue may be std:min, may signify something special) hence the lower end of the level window is set to min2ndValue - 0.5 * IR
For count(minValue) <= 20% the smallest values are not so important and can blend with the next ones => min(level window) = min2ndValue
And analog for max(level window): count(max2ndValue) > 20%: max(level window) = max2ndValue + 0.5 * IR count(max2ndValue) < 20%: max(level window) = max2ndValue
In both 20%+ cases the level window bounds are clamped to the [minValue, maxValue] range
In consequence the level window maximizes contrast with minimal amount of computation and does do useful things if the data contains std::min or std:max values or has only 1 or 2 or 3 data values.
Definition at line 260 of file mitkLevelWindow.cpp.
References mitk::PixelType::GetBpe(), mitk::PixelType::GetComponentType(), mitk::ImageStatisticsHolder::GetCountOfMaxValuedVoxelsNoRecompute(), mitk::ImageStatisticsHolder::GetCountOfMinValuedVoxelsNoRecompute(), mitk::Image::GetDimension(), mitk::Image::GetDimensions(), mitk::PixelType::GetPixelType(), mitk::Image::GetPixelType(), mitk::ImageStatisticsHolder::GetScalarValue2ndMaxNoRecompute(), mitk::ImageStatisticsHolder::GetScalarValue2ndMinNoRecompute(), mitk::ImageStatisticsHolder::GetScalarValueMaxNoRecompute(), mitk::ImageStatisticsHolder::GetScalarValueMin(), mitk::Image::GetStatistics(), mitk::BaseData::IsInitialized(), max(), min(), mitk::ImageSliceSelector::New(), and Update().
Referenced by QmitkBSplineRegistrationView::CalculateTransformation(), mitkLevelWindowTest(), mitkVtkPropRendererTest(), mitk::LevelWindowManager::RecaluclateLevelWindowForSelectedComponent(), mitk::GPUVolumeMapper3D::SetDefaultProperties(), and QmitkLevelWindowWidgetContextMenu::useOptimizedLevelWindow().
void mitk::LevelWindow::SetDefaultBoundaries | ( | mitk::ScalarType | low, |
mitk::ScalarType | up | ||
) |
void mitk::LevelWindow::SetDefaultLevelWindow | ( | mitk::ScalarType | level, |
mitk::ScalarType | window | ||
) |
set the default level and window value
Definition at line 124 of file mitkLevelWindow.cpp.
Referenced by LevelWindow().
void mitk::LevelWindow::SetFixed | ( | bool | fixed | ) |
If a level window is set to fixed, the set and get methods won't accept modifications to the level window settings anymore. This behaviour can be turned of by setting fixed to false;
Definition at line 442 of file mitkLevelWindow.cpp.
Referenced by mitk::LabeledImageLookupTable::LabeledImageLookupTable(), and QmitkLevelWindowWidgetContextMenu::setFixed().
void mitk::LevelWindow::SetFloatingValues | ( | bool | value | ) |
Sets the floating image value.
Definition at line 462 of file mitkLevelWindow.cpp.
void mitk::LevelWindow::SetLevelWindow | ( | mitk::ScalarType | level, |
mitk::ScalarType | window, | ||
bool | expandRangesIfNecessary = true |
||
) |
To set the level and the window value
Definition at line 129 of file mitkLevelWindow.cpp.
Referenced by mitk::DisplayInteractor::AdjustLevelWindow(), QmitkAdaptiveRegionGrowingToolGUI::ChangeLevelWindow(), QmitkLevelWindowWidgetContextMenu::changeScaleRange(), FLmitkComfortWidget::handle(), LevelWindow(), mitkLevelWindowTest(), QmlMitkSliderLevelWindowItem::mouseMoveEvent(), QmitkSliderLevelWindowWidget::mouseMoveEvent(), resetLevelWindow(), QmitkLevelWindowWidgetContextMenu::setDefaultScaleRange(), QmlMitkSliderLevelWindowItem::setLevel(), QmitkLineEditLevelWindowWidget::SetLevelValue(), QmitkLevelWindowWidgetContextMenu::setPreset(), QmlMitkSliderLevelWindowItem::setWindow(), and QmitkLineEditLevelWindowWidget::SetWindowValue().
void mitk::LevelWindow::SetRangeMinMax | ( | mitk::ScalarType | min, |
mitk::ScalarType | max | ||
) |
Set the range minimum and maximum value
Definition at line 163 of file mitkLevelWindow.cpp.
Referenced by QmitkLevelWindowWidgetContextMenu::changeScaleRange(), mitk::LabeledImageLookupTable::LabeledImageLookupTable(), mitkLevelWindowTest(), resetLevelWindow(), mitk::OtsuTool3D::RunSegmentation(), mitk::CompositeMapper::SetDefaultProperties(), mitk::ImageVtkMapper2D::SetDefaultProperties(), and mitk::DoseImageVtkMapper2D::SetDefaultProperties().
void mitk::LevelWindow::SetToImageRange | ( | const Image * | image | ) |
sets level/window to the min/max greyvalues of the given Image
!
Definition at line 426 of file mitkLevelWindow.cpp.
References mitk::ImageStatisticsHolder::GetScalarValueMaxNoRecompute(), mitk::ImageStatisticsHolder::GetScalarValueMin(), mitk::Image::GetStatistics(), and mitk::BaseData::IsInitialized().
Referenced by QmitkLevelWindowWidgetContextMenu::useAllGreyvaluesFromImage().
void mitk::LevelWindow::SetToMaxWindowSize | ( | ) |
sets the window to its maximum Size in scaleRange
Definition at line 189 of file mitkLevelWindow.cpp.
Referenced by QmitkLevelWindowWidgetContextMenu::setMaximumWindow().
void mitk::LevelWindow::SetWindowBounds | ( | mitk::ScalarType | lowerBound, |
mitk::ScalarType | upperBound, | ||
bool | expandRangesIfNecessary = true |
||
) |
Set the lower and upper bound of the window
Definition at line 134 of file mitkLevelWindow.cpp.
References swap().
Referenced by mitk::LabeledImageLookupTable::LabeledImageLookupTable(), mitkLevelWindowTest(), mitk::CompositeMapper::SetDefaultProperties(), mitk::ImageVtkMapper2D::SetDefaultProperties(), and mitk::DoseImageVtkMapper2D::SetDefaultProperties().
|
protected |
default minimum gray value of the window
Definition at line 228 of file mitkLevelWindow.h.
Referenced by operator==().
|
protected |
default maximum gray value of the window
Definition at line 233 of file mitkLevelWindow.h.
Referenced by operator==().
|
protected |
Defines whether the level window settings may be changed after initialization or not.
Definition at line 244 of file mitkLevelWindow.h.
|
protected |
Image with floating values
Definition at line 238 of file mitkLevelWindow.h.
|
protected |
lower bound of current window
Definition at line 208 of file mitkLevelWindow.h.
Referenced by EnsureConsistency(), and operator==().
|
protected |
maximum gray value of the window
Definition at line 223 of file mitkLevelWindow.h.
Referenced by EnsureConsistency(), and operator==().
|
protected |
minimum gray value of the window
Definition at line 218 of file mitkLevelWindow.h.
Referenced by EnsureConsistency(), and operator==().
|
protected |
upper bound of current window
Definition at line 213 of file mitkLevelWindow.h.
Referenced by EnsureConsistency(), and operator==().