I use numpy and scipy to handle multiple images taken with a CCD camera. These images have several hot (and dead) pixels with very large (or small) values. They interfere with other image processing, so they must be removed. Unfortunately, although some pixels are stuck at 0 or 255 and always have the same value in all images, there are some pixels that temporarily get stuck in other values for several minutes (data takes many hours).
I am wondering if there is a way to identify (and remove) hot pixels already implemented in python. If not, I wonder what would be an effective method for this. Hot / dead pixels are relatively easy to identify by comparing them with neighboring pixels. I could see how to write a loop that looks at each pixel, compares its value with its 8 nearest neighbors. Or, it seems better to use some kind of convolution to create a smoother image, and then subtract it from the image containing hot pixels, which makes their identification easier.
I tried this “blur method” in the code below and it works fine, but I doubt it is the fastest. In addition, it gets confused at the edge of the image (possibly because the gaussian_filter function takes a convolution, and the convolution becomes weird near the edge). So, is there a better way to do this?
Code example:
import numpy as np import matplotlib.pyplot as plt import scipy.ndimage plt.figure(figsize=(8,4)) ax1 = plt.subplot(121) ax2 = plt.subplot(122)
And the conclusion: 
python numpy scipy image-processing camera
Danickickstein
source share