【MISC】图片点阵提取

在打VNCTF2022的时候遇到这样一道题,图片直接放在文章肯能看不清,各位可以点开来仔细观看

放大来看

又是点阵图,这不就是妥妥的点阵提取嘛,打开画图,量出来点之间的距离,然后开造!
结果,出来很意外,每个点之间的距离都是不一样的,都在49~51之间浮动,这就导致直接提取不能提取出有效的信息
好在,每一行每一列的点都在同一条直线上,只要求出最左上角的点,然后跑出每一行每一列的坐标,再拼接即可
拼接的话可以使用OpenCV库,但是Python的PIL(Pillow)好像更胜一筹,于是学了一下写了个脚本

from PIL import Image,ImageDraw
image = Image.open("misc-img-pixel-1.png")
Line=[]
Row=[]
black=image.getpixel((0,0))
for i in range(image.height-1):
    if(image.getpixel((24,i))!=black):
        Row.append(i)
for i in range(image.width-1):
    if(image.getpixel((i,15))!=black):
        Line.append(i)
ret = Image.new('RGB', (len(Line), len(Row)) )
draw = ImageDraw.Draw(ret)
for x in range(len(Line)-1):
    for y in range(len(Row)-1):
        draw.point((x, y), fill=image.getpixel((Line[x],Row[y]))) 
ret.show()
ret.save('result.png')

继续阅读【MISC】图片点阵提取