How can you find rows and columns containing any marked pixel?

getprojection projects nonzero pixels onto each axis to return two occupancy sequences.

Pixel experiment and interpretation

Fill one cell in a three-by-two grid. The projections identify its row and column. With several objects the projections lose the original pairings.

from PIL import Image

im=Image.new('L',(3,2))
im.putpixel((2,0),7)
im.getprojection()

Result ([0, 0, 1], [1, 0])

中文

如何快速找出存在非零标记的行与列?

getprojection 将非零像素分别投影到横轴和纵轴,得到两个占用序列。

像素实验与适用边界

在 3×2 表格只填一个格。投影指出它所在的行列;多个目标的横纵投影无法还原全部配对。

from PIL import Image

im=Image.new('L',(3,2))
im.putpixel((2,0),7)
im.getprojection()

结果 ([0, 0, 1], [1, 0])

References / 参考来源

Keep reading / 继续阅读