For correcting a defective portion in image data having a plurality of
pixels, a plurality of first target pixels are selected one after another
from normal pixels. Any defective pixel is detected within a
predetermined area extending about each selected first target pixel as
its center and also a normal pixel present on an extension line
connecting the first target pixel and the defective pixel is detected and
set as a second target pixel. For each defective pixel present between
the first target pixel and the second target pixel, an interpolation
value is calculated. Further, for each pair of the first target pixel and
the second target pixel, a weight coefficient is calculated. The
technique stores such plurality of interpolation values and weight
coefficients. Then, by using the weight coefficient, a weighted average
value of the interpolation values for each defective pixel is calculated
and this weighted average value is used for the correction of each
defective pixel.