`
he_lux
  • 浏览: 102990 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

python challenge 11

阅读更多
第十一题。又是与图形打交道。页面中的图片看上去有重影,很像两幅图重叠的效果,页面的title写的又是odd even,很有可能是要把重叠在一起的两幅图分出来。但好像两张图片重叠在一起后,是不可能分出来的。在网上找了解题思路,原来是把原图的第奇数个像数点和第偶数个像素点各组成一幅图。
import Image

if __name__ == '__main__':
    
    img = Image.open('11.jpg')
    
    w = img.size[0]
    h = img.size[1]
    
    odd = even = Image.new(img.mode, (w/2, h/2))
    
    for x in range(w):
        for y in range(h):
            pixel = img.getpixel((x, y))
            if x % 2 == 0 and y % 2 == 0:
                odd.putpixel((x/2, y/2), pixel)
            elif x % 2 == 1 and y % 2 == 0:
                even.putpixel(((x-1)/2, y/2), pixel)
            elif x % 2 == 0 and y % 2 == 1:
                even.putpixel((x/2, (y-1)/2), pixel)
            elif x % 2 == 1 and y % 2 == 1:
                odd.putpixel(((x-1)/2, (y-1)/2), pixel)
                
    odd.show()
    even.show()

新的图片中显示了一个血淋淋的evil,就是它了!
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics