Patent ID: 7656561

Claim:
A method for lossless on-the-fly compression of raw digital image data from an image sensor, the method comprising: receiving information relating to a noise level and a gain of image data from the image sensor; receiving raw digital image data comprising a plurality of pixel values in one or more color planes from the image sensor; adjusting a pixel value distribution of the received raw digital image data to precondition the data for compression by applying a gain to the pixel values, the gain being at least partly determined by the received information; providing two or more prediction routines for predicting pixel values for pixels in clusters of neighboring pixels using other pixel values in the cluster; selecting, using the received information, a cluster size and an appropriate prediction routine for the image data or for each cluster; generating pixel prediction errors by, for each cluster and each color plane, predicting pixel values using the selected prediction routine, the pixel prediction error being derived from a difference between the predicted pixel value and the preconditioned pixel value, and evaluating an entropy figure for each cluster; providing two or more statistical encoding schemes, each determining codes and corresponding code lengths for pixel prediction errors of a cluster; encoding the pixel prediction errors of each cluster by, for each color plane, using the entropy figure and the received information to determine and select an appropriate statistical encoding scheme for the color plane of the cluster, and encoding the pixel prediction errors and the entropy of the cluster according to the selected statistical encoding scheme; and evaluating a length of a bit-stream corresponding to each line of the image, and appending the length to the bit-stream corresponding to the line and/or storing the length in an index table.