Skip to content

Instantly share code, notes, and snippets.

@godber
Created December 8, 2012 22:23
Show Gist options
  • Save godber/4242241 to your computer and use it in GitHub Desktop.
Save godber/4242241 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""Simple numpy script to generate a simulated dark image showing hot pixels"""
import numpy as np
from scipy import ndimage, misc
import matplotlib.pyplot as plt
# generate the image of zeros
im = np.zeros((1024, 1280))
# generate the coordinates for the hot pixels
n_hot = 400
hot_x = np.random.random_integers(0, im.shape[0]-2, n_hot)
hot_y = np.random.random_integers(0, im.shape[1]-2, n_hot)
# make the pixels two by two so they will be
# more visible
im[hot_x, hot_y] = 4095
im[hot_x+1, hot_y] = 4095
im[hot_x, hot_y+1] = 4095
im[hot_x+1, hot_y+1] = 4095
plt.imshow(im, cmap=plt.cm.gray)
misc.imsave('darks.png', im)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment