ファイル:Arnold's Cat Map animation (74px, zoomed, labelled).gif

提供: testwiki
ナビゲーションに移動 検索に移動
    元のファイル (224 × 263 ピクセル、ファイルサイズ: 1.95メガバイト、MIME タイプ: image/gif、ループします、117 フレーム、47秒)

    このファイルはウィキメディア・コモンズのものであり、他のプロジェクトで使用されている可能性があります。 ウィキメディア・コモンズでのファイル解説ページにある説明を以下に示します。

    解説
    English: Animation of Arnold's cat map (zoomed 3 times to make the pixels clearer, and labelled with the iteration number), using an image of cherries as the starting image. The image is 74 pixels square, and repeats after 114 iterations. Notice how the image sometimes contains superimposed cherries, many tiny cherries or a single perfectly reproduced but upside-down image. Used Cherry Stella444.jpg as starting image.
    日付
    原典 次の画像を基にした投稿者自身による著作物: Cherry Stella444.jpg:  次のものによる: Benjamint444
    作者 Inductiveload
    その他のバージョン

    ライセンス

    この作品の著作権者であるInductiveloadは、この作品を以下のライセンスで提供しています。
    w:ja:クリエイティブ・コモンズ
    表示 継承
    このファイルはクリエイティブ・コモンズ 表示-継承 3.0 非移植ライセンスのもとに利用を許諾されています。
    あなたは以下の条件に従う場合に限り、自由に
    • 共有 – 本作品を複製、頒布、展示、実演できます。
    • 再構成 – 二次的著作物を作成できます。
    あなたの従うべき条件は以下の通りです。
    • 表示 – あなたは適切なクレジットを表示し、ライセンスへのリンクを提供し、変更があったらその旨を示さなければなりません。これらは合理的であればどのような方法で行っても構いませんが、許諾者があなたやあなたの利用行為を支持していると示唆するような方法は除きます。
    • 継承 – もしあなたがこの作品をリミックスしたり、改変したり、加工した場合には、あなたはあなたの貢献部分を元の作品とこれと同一または互換性があるライセンスの下に頒布しなければなりません。

    Python source code

    #!/usr/bin/env python
    #-*- coding:utf-8 -*-
     
    import Image #needs PIL for image handling
    import ImageChops
    import ImageFont
    import ImageDraw
     
    # checks if two images are equal
    def equal(im1, im2):
        return ImageChops.difference(im1, im2).getbbox() is None
     
    # add a text caption to an image (adds space at the bottom)
    def addCaption(im, text, pointSize):
        size = im.size
        draw = ImageDraw.Draw(im)
     
        textFontLocation = "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf"
        topBottomMargin = 5
     
        textFont = ImageFont.truetype(textFontLocation ,pointSize)
        textSize = draw.textsize(text, font=textFont) # the size of the text box!
     
        newImage = Image.new(im.mode,\
                (im.size[0], im.size[1]+textSize[1]+2*topBottomMargin), "white" )
        newImage.paste( im, (0,0) )
        draw = ImageDraw.Draw(newImage)
     
        textX = (newImage.size[0] / 2.0) - (textSize[0] / 2.0)
        textY = newImage.size[1] - textSize[1] - topBottomMargin
     
        draw.text((textX, textY), text, fill="black", font=textFont)
        return newImage
     
    # add a solid border to an image
    def addBorder(im, color, thickness):
        newImage = Image.new(im.mode,\
                (im.size[0]+thickness*2, im.size[1]+thickness*2), color)
        newImage.paste( im, (1,1) )
        return newImage
     
    # scale an image up or down (doesn't resample, so the pixels are clear)
    def scaleImage(im, factor):
        newImage = Image.new(im.mode,\
                (im.size[0]*factor, im.size[1]*factor), "white" )
        newImage.paste( im.transform((im.size[0]*factor, im.size[1]*factor),\
                Image.AFFINE,\
                (1/float(factor),0,0,0,1/float(factor),0) ),\
                (0,0) )
        return newImage
     
    def saveImages(im, iteration):
        im.save("Catmap%04d.png"%iteration) #save the simple image
     
        #resize image, add border and caption
        imageLarge = scaleImage(im, 6)
        imageLarge = addBorder(imageLarge, "black", 1)
        imageLarge = addCaption(imageLarge, str(iteration), 40)
        imageLarge.save("CatmapLargeNumbered%04d.png"%iteration)
     
    # CONTROL STARTS HERE
     
    inFile = "aa-catmap-orig.resized.jpg" #input image
     
    image0 = Image.open(inFile, 'r')
     
    #crop to square if required
    if image0.size[0] != image0.size[1]:
        n = min(image0.size[0], image0.size[1] )
        image0 = image0.crop((0,0,n,n))
    else:
        n = image0.size[0]
     
    imageOrig = image0.copy() # keep to original image to see when we return to it
     
    image1 = Image.new(image0.mode, (n,n)) # temp image to copy pixels to
    pixels1 = image1.load()
     
    # BEGIN THE CAT MAPPING PROCESS
     
    iteration = 0
    saveImages(image0, iteration) # save the first image
    while True:
        pixels0 = image0.load() #reload the iterated image
     
        for x in range(n):# perform the mapping
            for y in range(n):
                newX = (2*x + y) % n #find new location
                newY = (x + y) % n
                pixels1[newX, newY] = pixels0[x, y] # copy the pixel over
     
        image0 = image1.copy() #transfer back to image0 for the next iteration
        iteration += 1
        saveImages(image0, iteration) # save this iteration's image
     
        if equal(image0, imageOrig):
            break
    

    キャプション

    このファイルの内容を1行で記述してください
    The phase portrait of Arnold's cat map.

    このファイルに描写されている項目

    題材

    16 9 2010

    15d48a9deeea7020f0ed1b1994353ca581c394b1

    2,042,441 バイト

    46.7999999999999 秒

    263 ピクセル

    224 ピクセル

    ファイルの履歴

    過去の版のファイルを表示するには、その版の日時をクリックしてください。

    日時サムネイル寸法利用者コメント
    現在の版2010年9月15日 (水) 20:142010年9月15日 (水) 20:14時点における版のサムネイル224 × 263 (1.95メガバイト)wikimediacommons>Inductiveload{{Information |Description={{en|Animation of en:Arnold's cat map (zoomed 3 times to make the pixels clearer, and labelled with the iteration number), using an image of cherries as the starting image. The image is 74 pixels square, and repeats after

    このファイルを使用しているページはありません。