bool ImageData::regulate_wl(float& window, float& level, bool regulate_to_positive) {
// CT should apply slope and intercept
// MR has always slope(1) and intercept(0)
if (_slope < DOUBLE_EPSILON) {
return false;
}
if (regulate_to_positive && (_data_type == DT_SHORT || _data_type == DT_CHAR)) {
const float min_gray = get_min_scalar();
level = (level - _intercept - min_gray) / _slope;
}
else {
level = (level - _intercept) / _slope;
}
window = window / _slope;
return true;
}