How can a reference ramp test which image axis varies?

linear_gradient generates a standard top-to-bottom ramp for checking orientation and intensity mappings.

Pixel experiment and interpretation

Probe upper left, upper right and lower left. The top pair match because variation follows the vertical axis. A mistaken transpose reverses that relationship.

from PIL import Image

im=Image.linear_gradient('L')
[im.getpixel(p) for p in [(0,0),(255,0),(0,255)]]

Result [0, 0, 255]

中文

怎样生成有已知方向的灰度坡来检查图像轴?

linear_gradient 生成从上到下变化的标准渐变图,适合检查方向与灰度映射。

像素实验与适用边界

读出左上、右上和左下三个点。两处顶部值相同,说明变化沿纵轴;意外转置会把这套关系反过来。

from PIL import Image

im=Image.linear_gradient('L')
[im.getpixel(p) for p in [(0,0),(255,0),(0,255)]]

结果 [0, 0, 255]

References / 参考来源

Keep reading / 继续阅读