参考博客
3Dslicer1:入门及基本控制
自动窗宽窗位的一些思路
How auto W/L is implemented in 3DSlicer?
python代码
根据How auto W/L is implemented in 3DSlicer?实现
// auto W/L def auto_wl(img, low 0.1, high 0.99): imhist, bins np.histogram(img.flatten(), int(math.ceil(img.max()) - np.min(img[img -math.inf]) 1), range (np.min(img[img -math.inf]), math.ceil(img.max())), density True) pre_sum np.zeros(shape imhist.shape) temp_sum 0 for i in range(pre_sum.shape[0]): temp_sum imhist[i] pre_sum[i] temp_sum f interp1d(pre_sum, bins[:-1], bounds_error False, fill_value 0) low_value, high_value f(low), f(high) assert high_value 0 l math.ceil(low_value high_value / 2) w math.floor(high_value - low_value) return w, l
效果
Fixed W/L
Auto W/L
可以看到对比度观感有明显提升



