Skip to content

Instantly share code, notes, and snippets.

@ehrentreu
Created October 31, 2019 22:45
Show Gist options
  • Save ehrentreu/ab5bb0113847429ee45ea643fdadd222 to your computer and use it in GitHub Desktop.
Save ehrentreu/ab5bb0113847429ee45ea643fdadd222 to your computer and use it in GitHub Desktop.
%pylab inline
BRUSH_STROKE_SIZE = 4
palette = imread('palette.png')
image = imread('starry-night-800.jpg')
png = np.ones(image.shape)
num_of_strokes = [1000, 10000, 100000]
for num in num_of_strokes:
for index in range(num):
row = np.random.randint(0, png.shape[0]-4)
column = np.random.randint(0, png.shape[1]-4)
color = np.random.randint (0, palette.shape[1]-1)
png[row:row + BRUSH_STROKE_SIZE, column:column + BRUSH_STROKE_SIZE] = palette[0,color]
imshow(png)
figure()
imsave(f"random{num//1000}k.png", png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment