Drkcore

21 10 2009 Python PIL glitch Tweet

夕焼けグリッチ

5x5のタイル状にしてみた。

1256111943

好みの夕暮れの色があるように、好みのノイズ量があるに違いないので、もう少しノイズの入れ方を考えないと。

import base64,re,Image
from random import randint

def glitch(infile,outfile):
    jpg_text = base64.encodestring(open(infile,"rb").read())
    glitched_text = ""
    count = 0
    width,height = Image.open(infile).size
    num = width * height / 10000
    for c in jpg_text:
        if c == '0':
            if randint(0,num) == 0:
                count += 1
                glitched_text += str(randint(0,9))
            else:
                glitched_text += c
        else:
            glitched_text += c
    glitched_jpg = base64.decodestring(glitched_text)
    open(outfile,"wb").write(glitched_jpg)
    return count
if __name__ == '__main__':
    for i in range(25):
        outfile = "test_%d.jpg" % i
        count = glitch("/Users/kzfm/yuki3.jpg",outfile)
        #print "%d: %d" % (i,count)

    tiled_im = Image.new('RGB',(1600,1200))
    tiled_px = tiled_im.load()
    for i in range(5):
        for j in range(5):
            n = 5*i+j;
            imgfile = "/Users/kzfm/python/test_%d.jpg" % n
            im = Image.open(imgfile)
            px = im.load()
            for x in range(320):
                for y in range(240):
                    nx = 320 * j + x
                    ny = 240 * i + y
                    tiled_px[nx,ny] = px[x,y]
    tiled_im.show()

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021