Created
December 8, 2012 22:23
-
-
Save godber/4242241 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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