Window width/level range calculation

Hi, recently I found the automatic adjustion of window width and level using a selected region in Slicer was quite useful. I want to implement it in my own way in python using SimpleITK. I’ve checked VTK website but found littile information there. Here is what I found in the forum (a simlilar topic How to change window/level programmatically) and locate the algorithm right here: VTK/vtkImageHistogramStatistics.cxx at 6a9c565da01bcd6295d0bcbb66c0a9d0d2eaa69e · Kitware/VTK · GitHub

I was wondering whether the range is calculated based on the histogram or simply min-max value of selected region.

Window/Level based on selection area is discussed at Feedback requested: How to improve mouse interaction in views? - #12 by lassoan

Auto Window/Level was changed from a histogram bimodal analysis to a fixed percentile based method. It was updated in Slicer as ENH: Improved automatic scalar volume display window/level computation · Slicer/Slicer@bc0d938 · GitHub

Thanks lot. It wll be of great help if you can explain the idea behind the auto-windowing method of selection area. :smiley: