This got solved in an email thread… so, posting the results here:
# DEFECT PIXEL CORRECTION FOR GLOBAL SHUTTER MODULE import sensor, image, time def defect_pixel_correction(img, point_list): """ Input is an image object 'img' and a list of points [(x,y),(x,y),etc.] """ for p in point_list: val_list =  for i in range(3): for j in range(3): val = img.get_pixel(p+i-1, p+j-1) val_list.append(val) val_list.sort() # median try: # for the case that this pixel is on the image border img.set_pixel(p, p, val_list) except: pass def defect_pixel_correction_2(img, point_list): # instead of median the value of one neighbor pixel is copied for p in point_list: try: # for the case that this pixel is on the image border img.set_pixel(p, p, img.get_pixel(p+1, p)) except: pass def find_defect_pixels(): # if you use this, you have to cover the lens before starting this code thresh = 20 img = sensor.snapshot() ind =  for posx in range(sensor.width()): for posy in range(sensor.height()): if img.get_pixel(posx, posy) > thresh: ind.append((posx, posy)) return ind sensor.reset() # Reset and initialize the sensor. sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE) sensor.set_framesize(sensor.WVGA2) # Set frame size to QVGA (320x240) sensor.skip_frames(time = 2000) # Wait for settings take effect. clock = time.clock() # Create a clock object to track the FPS. correction = 2 # 0 = no correction # 1 = median correction (lens must be covered at the beginning) # recommended for low resolution (e.g. QQVGA) # 2 = copy one neighbor pixel (lens must be covered at the beginning) # recommended for high resolution (e.g. WVGA2) if correction > 0: ind = find_defect_pixels() while(True): clock.tick() # Update the FPS clock. img = sensor.snapshot() # Take a picture and return the image. if correction == 1: defect_pixel_correction(img, ind) elif correction == 2: defect_pixel_correction_2(img, ind) print(clock.fps()) # Note: OpenMV Cam runs about half as fast when connected # to the IDE. The FPS should increase once disconnected.