How can channel extrema reveal a constant band?
getextrema gives the minimum and maximum of each band. Equal endpoints identify a constant band.
Pixel experiment and interpretation
Vary only green between two points. Red and blue collapse to single values; the ranges cannot locate the change.
from PIL import Image
im=Image.new('RGB',(2,1))
im.putdata([(10,30,40),(10,80,40)])
im.getextrema()Result ((10, 10), (30, 80), (40, 40))
中文
如何快速判断某个颜色通道是否完全恒定?
getextrema 返回每个通道的最小值和最大值,两端相等说明该通道没有变化。
像素实验与适用边界
两点之间只改变绿色。红、蓝范围都折叠到一个值;这项检查不会告诉你绿色的变化发生在哪里。
from PIL import Image
im=Image.new('RGB',(2,1))
im.putdata([(10,30,40),(10,80,40)])
im.getextrema()结果 ((10, 10), (30, 80), (40, 40))