第28关
RING-RING-RING,读着读着就变成了GREEN. green.html里提示yes, green.
仔细观察一下图片,发现里面有一条条的绿色竖纹。将图片的Green通道提取出来,相邻的两列像素作差,得到的差值的绝对值几乎都为42,只有少数例外。将绝对值不是42的提取出来,转成ASCII,得到通关信息——Python作者的姓名Guido van Rossum中的guido
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| from PIL import Image import numpy as np
im = Image.open('bell.png') imdata = list(im.getdata()) imdata = np.array(imdata) size = im.size imdata = imdata.reshape((size[1], size[0], -1)) imdata_g = imdata[:, :, 1] diff = np.abs(imdata_g[:, 0::2] - imdata_g[:, 1::2]) idx = np.where(diff != 42) msg = diff[idx]
print ''.join(chr(i) for i in msg)
print 'Guido van Rossum'.split()[0]
|
下一关 http://www.pythonchallenge.com/pc/ring/guido.html
参考