Effectively defect free images are obtained from CMOS image sensors through
a two step method in which the addresses of bad pixels are recorded during sensor
testing and stored in an on-chip directory. Then, during sensor readout, each pixel
address is checked to determine if it represents that of a bad pixel. If this is
determined to be the case, the bad pixel value is replaced by another value. This
replacement value is generated from an average of the nearest-neighbors that are
not defective. If testing is performed at the wafer level, said bad pixel and nearest
neighbor data may be used to modify the final level wiring so that bad pixels are
disconnected and replaced by their nearest neighbors.