A demosaic system and method that supports multiple CFA pattern inputs is
disclosed. The demosaic system is capable of handling both RGB Bayer
input and CMYG input and perform demosaic operations on both inputs to
recover full-color images from the raw input images. The system uses a
variable number gradient demosiac process. The process uses a 5.times.5
neighborhood of sensor pixel data centered at the pixel under
consideration. The process calculates a set of gradients corresponding to
different directions within the neighborhood of the sensor pixel data. A
threshold value is determined and a subset of gradients is selected from
the set of gradients that fall below the threshold value. The system
calculates estimation values for the missing color value and the actual
measured center pixel color value obtained from the sensor data on
directions that are within the subset of gradients below the threshold.
The system then determines the sum of the missing color estimation values
and the sum of the actual center pixel color estimation values. The
system interpolates the missing color value by using the average
difference of the summed estimation values for the missing color and the
summed estimation values for the actual center measured pixel value from
the sensor data.