Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkLevelWindow.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 #ifndef mitkLevelWindow_h
13 #define mitkLevelWindow_h
14 
15 #include <mitkNumericTypes.h>
16 #include <MitkCoreExports.h>
17 #include <nlohmann/json_fwd.hpp>
18 
19 namespace mitk
20 {
21  class Image;
22 
44  {
45  public:
51  LevelWindow(ScalarType level = 127.5, ScalarType window = 255.0);
52 
58 
60  virtual ~LevelWindow();
61 
67 
73 
79 
85 
90 
96 
102 
109  void SetLevelWindow(ScalarType level, ScalarType window, bool expandRangesIfNecessary = true);
110 
120  void SetWindowBounds(ScalarType lowerBound, ScalarType upperBound, bool expandRangesIfNecessary = true);
121 
126 
133 
139 
145 
151 
157 
162 
168 
175 
182 
196  void SetAuto(const Image *image,
197  bool tryPicTags = true,
198  bool guessByCentralSlice = true,
199  unsigned selectedComponent = 0);
200 
205  void SetToImageRange(const Image *image);
206 
214  void SetFixed(bool fixed);
215 
221  bool GetFixed() const;
222 
228  bool IsFixed() const;
229 
235  virtual bool operator==(const LevelWindow &levWin) const;
236 
242  virtual bool operator!=(const LevelWindow &levWin) const;
243 
249  virtual LevelWindow &operator=(const LevelWindow &levWin);
250 
255  bool IsFloatingValues() const;
256 
261  void SetFloatingValues(bool value);
262 
263  protected:
268 
273 
278 
283 
288 
293 
298 
303  bool m_Fixed;
304 
320  inline void EnsureConsistency();
321  };
322 
325 
326 } // namespace mitk
327 #endif
#define MITKCORE_EXPORT
Image class for storing multi-dimensional medical image data.
Definition: mitkImage.h:76
The LevelWindow class Class to store level/window values.
ScalarType GetRangeMax() const
Get the maximum of the valid value range.
void SetToImageRange(const Image *image)
Set level/window to the full min/max grey value range of the given image.
bool IsFixed() const
Return whether the level window settings are fixed.
ScalarType GetRange() const
Get the total size of the grey value range (max - min).
void ResetDefaultLevelWindow()
Reset the level and window to their default values.
void SetAuto(const Image *image, bool tryPicTags=true, bool guessByCentralSlice=true, unsigned selectedComponent=0)
Automatically set level/window to optimize image contrast.
LevelWindow(ScalarType level=127.5, ScalarType window=255.0)
Construct a LevelWindow with given level (center) and window (range) values.
LevelWindow(const mitk::LevelWindow &levWin)
Copy constructor.
bool IsFloatingValues() const
Check whether the image uses floating-point values.
ScalarType GetRangeMin() const
Get the minimum of the valid value range.
void SetFloatingValues(bool value)
Set whether the image uses floating-point values.
bool GetFixed() const
Return whether the level window settings are fixed.
void SetDefaultLevelWindow(ScalarType level, ScalarType window)
Set the default level and window values.
void SetFixed(bool fixed)
Lock or unlock the level window settings.
ScalarType GetDefaultUpperBound() const
Get the default upper bound (default range maximum).
ScalarType GetDefaultWindow() const
Get the default window size for the image.
ScalarType m_DefaultLowerBound
ScalarType m_DefaultUpperBound
ScalarType GetDefaultLevel() const
Get the default level value for the image.
ScalarType GetLowerWindowBound() const
Get the lower bound of the current window.
ScalarType GetDefaultLowerBound() const
Get the default lower bound (default range minimum).
virtual ~LevelWindow()
Virtual destructor.
void SetDefaultBoundaries(ScalarType low, ScalarType up)
Set the default lower and upper boundaries.
virtual bool operator!=(const LevelWindow &levWin) const
Compare two LevelWindow objects for inequality.
void SetLevelWindow(ScalarType level, ScalarType window, bool expandRangesIfNecessary=true)
Set the level and window values.
ScalarType GetUpperWindowBound() const
Get the upper bound of the current window.
ScalarType GetLevel() const
Get the level value, i.e. the center of the current grey value interval.
void ResetDefaultRangeMinMax()
Reset the range min/max to the default boundaries.
void SetWindowBounds(ScalarType lowerBound, ScalarType upperBound, bool expandRangesIfNecessary=true)
Set the lower and upper window bounds directly.
ScalarType GetWindow() const
Get the current window size, i.e. the width of the current grey value interval.
void SetRangeMinMax(ScalarType min, ScalarType max)
Set the minimum and maximum of the valid value range.
void SetToMaxWindowSize()
Set the window to cover the entire valid range.
void EnsureConsistency()
virtual bool operator==(const LevelWindow &levWin) const
Compare two LevelWindow objects for equality.
ScalarType m_UpperWindowBound
virtual LevelWindow & operator=(const LevelWindow &levWin)
Assignment operator.
ScalarType m_LowerWindowBound
nlohmann::json json
Convenience header that includes all MITK numeric types.
class ITK_EXPORT Image
Find image slices visible on a given plane.
void from_json(const nlohmann::json &, GenericLookupTable< T > &)
Deserialize a GenericLookupTable from JSON.
void to_json(nlohmann::json &j, const GenericLookupTable< T > &t)
Serialize a GenericLookupTable to JSON.
double ScalarType
Scalar type used throughout MITK for geometric computations.