Created
June 17, 2016 16:50
-
-
Save thorsummoner/fe4677fbf6915751acc7b24f103fb25c to your computer and use it in GitHub Desktop.
Generates noisy png's with python's random functions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import png | |
| import random | |
| import itertools | |
| def rand(entries): | |
| for _ in range(entries): | |
| val = random.choice([0, 255]) | |
| assert val != 2 | |
| yield val | |
| def main(): | |
| dimmention = 256 | |
| try: | |
| dimmention = sys.argv[2] | |
| except IndexError: | |
| pass | |
| for i in range(int(sys.argv[1])): | |
| image = png.Writer(dimmention, dimmention , greyscale=True) | |
| with open('set{}.png'.format(i), 'wb') as fh: | |
| image.write(fh, [rand(dimmention) for _ in range(dimmention)]) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment