Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nonZero/bc041ac9e19649617b014c5419c2a48e to your computer and use it in GitHub Desktop.
Save nonZero/bc041ac9e19649617b014c5419c2a48e 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