How can a mode filter repair an isolated wrong label?

ModeFilter selects a frequent neighborhood value and ignores candidates appearing at most twice.

Pixel experiment and interpretation

Eight neighbors vote for class 3 around an erroneous 8. A mode vote repairs the center but can erase sparse narrow targets.

from PIL import Image, ImageFilter

im=Image.new('L',(3,3),3)
im.putpixel((1,1),8)
im.filter(ImageFilter.ModeFilter(3)).getpixel((1,1))

Result 3

中文

众数滤波如何修补类别图中的孤立错误标签?

ModeFilter 选取邻域中频繁出现的值;出现不超过两次的候选会被忽略。

像素实验与适用边界

周围八个像素都标为 3,中心误标为 8。用众数能够恢复类别;稀疏的细目标则可能被周围类别吞没。

from PIL import Image, ImageFilter

im=Image.new('L',(3,3),3)
im.putpixel((1,1),8)
im.filter(ImageFilter.ModeFilter(3)).getpixel((1,1))

结果 3

References / 参考来源

Keep reading / 继续阅读