File:Red-noise-fail-01.jpg
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
Size of this preview: 800 × 450 pixels. Other resolutions: 320 × 180 pixels | 640 × 360 pixels | 1,024 × 576 pixels | 1,280 × 720 pixels | 2,560 × 1,440 pixels.
Original file (2,560 × 1,440 pixels, file size: 269 KB, MIME type: image/jpeg)
File information
Structured data
Captions
Summary
[edit]DescriptionRed-noise-fail-01.jpg |
Deutsch: Ein fehlgeschlagener Versuch red noise zu erzeugen |
Date | |
Source | Own work |
Author | MartinThoma |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Create a red noise RGB image of the dimensions you want."""
import numpy
import Image
import random
def create_red_noise(outfile, width, height, r=10):
"""
Create red noise RGB image
Parameters
----------
outfile : str
width : int
height : int
r : int
Random maximum offset compared to the last pixel
"""
array = numpy.random.rand(height, width, 3) * 255
for x in range(width):
for y in range(height):
if y == 0:
if x == 0:
continue
else:
for i in range(3):
array[y][x][i] = (array[y][x-1][i] +
random.randint(-r, r))
else:
if x == 0:
for i in range(3):
array[y][x][i] = (array[y-1][x][i] +
random.randint(-r, r))
else:
for i in range(3):
array[y][x][i] = (((array[y-1][x][i] +
array[y-1][x-1][i]) / 2.0 +
random.randint(-r, r)))
im_out = Image.fromarray(array.astype('uint8')).convert('RGBA')
im_out.save(outfile)
def get_parser():
"""Get parser object for create_random_image.py."""
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
parser = ArgumentParser(description=__doc__,
formatter_class=ArgumentDefaultsHelpFormatter)
parser.add_argument("-f", "--file",
dest="filename",
help="write red noise image to FILE",
default="red-noise.jpg",
metavar="FILE")
parser.add_argument("-x", "--width",
dest="width",
default=1280,
type=int,
help="width of the image")
parser.add_argument("-y", "--height",
dest="height",
default=960,
type=int,
help="height of the image")
parser.add_argument("-o", "--offset",
dest="offset",
default=10,
type=int,
help="maximum offset compared to the neighbors")
return parser
if __name__ == "__main__":
args = get_parser().parse_args()
create_red_noise(args.filename, args.width, args.height, args.offset)
Licensing
[edit]I, the copyright holder of this work, hereby publish it under the following license:
This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. | |
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 10:53, 10 June 2016 | 2,560 × 1,440 (269 KB) | MartinThoma (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
There are no pages that use this file.