MCPcopy Create free account
hub / github.com/MITK/MITK / SetAuto

Method SetAuto

Modules/Core/src/DataManagement/mitkLevelWindow.cpp:260–445  ·  view source on GitHub ↗

! 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 max

Source from the content-addressed store, hash-verified

258std:max values or has only 1 or 2 or 3 data values.
259*/
260void mitk::LevelWindow::SetAuto(const mitk::Image *image,
261 bool /*tryPicTags*/,
262 bool guessByCentralSlice,
263 unsigned selectedComponent)
264{
265 if (IsFixed())
266 return;
267
268 if (image == nullptr || !image->IsInitialized())
269 return;
270
271 if (itk::IOComponentEnum::FLOAT == image->GetPixelType().GetComponentType()
272 || itk::IOComponentEnum::DOUBLE == image->GetPixelType().GetComponentType())
273 {
274 m_IsFloatingImage = true;
275 }
276 else
277 {
278 m_IsFloatingImage = false;
279 }
280
281 const mitk::Image *wholeImage = image;
282 ScalarType minValue = 0.0;
283 ScalarType maxValue = 0.0;
284 ScalarType min2ndValue = 0.0;
285 ScalarType max2ndValue = 0.0;
286 mitk::ImageSliceSelector::Pointer sliceSelector = mitk::ImageSliceSelector::New();
287 if (guessByCentralSlice)
288 {
289 sliceSelector->SetInput(image);
290 sliceSelector->SetSliceNr(image->GetDimension(2) / 2);
291 sliceSelector->SetTimeNr(image->GetDimension(3) / 2);
292 sliceSelector->SetChannelNr(image->GetDimension(4) / 2);
293 sliceSelector->Update();
294 image = sliceSelector->GetOutput();
295 if (image == nullptr || !image->IsInitialized())
296 return;
297
298 minValue = image->GetStatistics()->GetScalarValueMin(0, selectedComponent);
299 maxValue = image->GetStatistics()->GetScalarValueMaxNoRecompute();
300 min2ndValue = image->GetStatistics()->GetScalarValue2ndMinNoRecompute();
301 max2ndValue = image->GetStatistics()->GetScalarValue2ndMaxNoRecompute();
302 if (minValue == maxValue)
303 {
304 // guessByCentralSlice seems to have failed, lets look at all data
305 image = wholeImage;
306 minValue = image->GetStatistics()->GetScalarValueMin(0, selectedComponent);
307 maxValue = image->GetStatistics()->GetScalarValueMaxNoRecompute();
308 min2ndValue = image->GetStatistics()->GetScalarValue2ndMinNoRecompute();
309 max2ndValue = image->GetStatistics()->GetScalarValue2ndMaxNoRecompute();
310
311 if (minValue == maxValue)
312 {
313 // Same result, also look at data at other time steps if present...
314 auto numTimeSteps = image->GetTimeGeometry()->CountTimeSteps();
315
316 if (numTimeSteps > 1)
317 {

Callers 9

CreateResultNodeMethod · 0.80
SetDefaultPropertiesMethod · 0.80
mitkLevelWindowTestFunction · 0.80
SetDefaultPropertiesMethod · 0.80
StartButtonClickedMethod · 0.80
StartButton2ClickedMethod · 0.80
StartButtonClickedMethod · 0.80

Calls 13

GetComponentTypeMethod · 0.80
GetScalarValueMinMethod · 0.80
GetStatisticsMethod · 0.80
GetBpeMethod · 0.80
GetDimensionsMethod · 0.80
NewFunction · 0.50
IsInitializedMethod · 0.45
GetPixelTypeMethod · 0.45
SetInputMethod · 0.45
GetDimensionMethod · 0.45
UpdateMethod · 0.45
GetOutputMethod · 0.45

Tested by 1

mitkLevelWindowTestFunction · 0.64