FIELD OF THE INVENTION  
       [0001]     This invention relates to image processing and particularly to a restoration of colour components in a system for storage or acquisition of digital images.  
       BACKGROUND OF THE INVENTION  
       [0002]     Blurring or degradation of an image can be caused by various factors, e.g. out-of-focus optics, or any other aberrations that result from the use of a wide-angle lens, or the combination of inadequate aperture value, focal length and lens positioning. During the image capture process, when long exposure times are used, the movement of the camera, or the imaged subject, can result in motion blurring of the picture. Also, when short exposure time is used, the number of photons being captured is reduced, this results in high noise levels, as well as poor contrast in the captured image.  
         [0003]     Various methods for restoring images that contain defects, e.g. blurring, are known from related art. For example spatial error concealment techniques attempt to hide a defect by forming a good reconstruction of the missing or corrupted pixels. One of the methods is to find a mean of the pixels in an area surrounding the defect and to replace the defect with the mean pixel value. A requirement for the variance of the reconstruction can be added to equal the variance of the area around the defect.  
         [0004]     Different interpolation methods can also be used for restoration. For example a bilinear interpolation can be applied to pixels on four corners of the defect rectangle. This makes a linear, smooth transition of pixel values across the defect area. Bilinear interpolation is defined by the pixel value being reconstructed, pixels at corners of the reconstructed pixel and a horizontal and vertical distance from the reconstructed pixel to the corner pixels. Another method is edge-sensitive nonlinear filtering, which interpolates missing samples in an image.  
         [0005]     The defect block can be replaced also with the average of some of all of the surrounding blocks. One example is to use three blocks that are situated above the defect. Further there is a method called “best neighbours matching” which restores images by taking a sliding block the same size as the defect region and moves it through the image. At each position, except for ones where the sliding block overlaps the defect, the pixels around the border of the sliding block are placed in a vector. The pixel values around the border of the defect are placed in another vector and the mean squared error between them is computed. The defect region is then replaced by the block that has the lowest border-pixel.  
         [0006]     The purpose of image restoration is to remove those degradations so that the restored images look as close as possible to the original scene. In general, if the degradation process is known; the restored image can be obtained as the inverse process of the degradation. Several methods to solve for this inverse mathematical problem are known from the prior art. However, most of these techniques do not consider the image reconstruction process in the modelling of the problem, and assume simplistic linear models. Typically, the solutions in implementations are quite complicated and computationally demanding.  
         [0007]     The methods from related art are typically applied in restoration of images in high-end applications such as astronomy and medical imaging. Their use in consumer products is limited, due to the difficulty of quantifying the image gathering process and the typical complexity and computational power needed to implement these algorithms. Some of the approaches have been used in devices that have limited computational and memory resources. The methods from the related art are typically designed as a post-processing operation, which means that the restoration is applied to the image, after it has been acquired and stored. In a post-processing operation each colour component has a different point spread function that is an important criteria that can be used to evaluate the performance of imaging systems. If the restoration is applied as post-processing, the information about the different blurring in each colour component is not relevant anymore. The exact modelling of the image acquisition process is more difficult and (in most cases) is not linear. So the “inverse” solution is less precise. Most often, the output of the digital cameras is compressed to .jpeg-format. If the restoration is applied after the compression (which is typically lossy), the result can amplify unwanted blocking artefacts.  
       SUMMARY OF THE INVENTION  
       [0008]     The aim of this invention is to provide an improved way to restore images. This can be achieved by a method, a model, use of a model, a device, a module, a system, a program module and a computer program product.  
         [0009]     According to present invention the method for forming a model for improving image quality of a digital image captured with an imaging module comprising at least imaging optics and an image sensor, where the image is formed through the imaging optics, said image consisting of at least one colour component, wherein degradation information of each colour component is found, an image degradation function is obtained and said each colour component is restored by said degradation function.  
         [0010]     According to present invention also the model for improving image quality of a digital image is provided, said model being obtainable by a claimed method. According to the present invention also use of the model is provided.  
         [0011]     Further according to present invention the method for improving image quality of a digital image captured with an imaging module comprising at least imaging optics and an image sensor is provided, where the image is formed through the imaging optics, said image consisting at least of one colour component, wherein degradation information of each colour component of the image is found, a degradation function is obtained according to the degradation information and said each colour component is restored by said degradation function.  
         [0012]     Further according to present invention a system for determining a model for improving image quality of a digital image with an imaging module is provided, said module comprising at least imaging optics and an image sensor, where the image is formed through the imaging optics, said image consisting of at least one colour component, wherein the system comprises first means for finding degradation information of each colour component of the image, second means for obtaining a degradation function according to the degradation information, and third means for restoring said each colour component by said degradation function.  
         [0013]     Further according to present invention the imaging module is provided, comprising imaging optics and an image sensor for forming an image through the imaging optics onto the light sensitive image sensor wherein a model for improving image quality is related to said imaging module. Further according to present invention a device comprising an imaging module is provided.  
         [0014]     In addition, according to present invention the program module for improving an image quality in a device is provided, comprising an imaging module, said program module comprising means for finding degradation information of each colour component of the image, obtaining a degradation function according to the degradation information, and restoring said each colour component by said degradation function. Further the computer program product is provided, comprising instructions for finding degradation information of each colour component of the image, obtaining a degradation function according to the degradation information, and restoring said each colour component by said degradation function.  
         [0015]     Other features of the invention are described in appended dependent claims.  
         [0016]     In the description a term “first image model” corresponds to such an image, which is already captured with an image sensor, such as a CCD (Charged Coupled Device) or CMOS (Complementary Metal Oxide Semiconductor), but not processed in any way. The first image model is raw image data. The second image model is the one for which a degradation information has been determined. It will be appreciated that other sensor types, other than CMOS or CCD can be used with the invention.  
         [0017]     The first image model is used for determining the blurring of the image, and the second image model is restored according to the invention. The restoration can also be regulated according to the invention. After these steps have been done, other image reconstruction functions can be applied to it. If considering the whole image reconstruction chain, the idea of the invention is to apply the restoration as a pre-processing operation, whereby the following image reconstruction operations will benefit from the restoration. Applying the restoration as a pre-processing operation means that the restoration algorithm is targeted directly to the raw colour image data and in such a manner, that each colour component is handled separately.  
         [0018]     With the invention the blurring caused by optics can be reduced significantly. The procedure is particularly effective if fixed focal length optics is used. The invention is also applicable to varying focal length systems, in which case the processing considers several deblurring functions from a look-up table depending on the focal position of the lenses. The deblurring function can also be obtained through interpolation from look-up tables. One possibility to define the deblurring function is to use continuous calculation, in which focal length is used as a parameter to deblurring function. The resulting images are sharper and have better spatial resolution. It is worth mentioning that the proposed processing is different from traditional sharpening algorithms, which can also result in sharper images with amplified high-frequencies. In fact, this invention presents a method to revert the degradation process and to minimize blurring, which is caused e.g. by optic, whereas the sharpening algorithms use generic high-pass filters to add artefacts to an image in order to make it look sharper.  
         [0019]     The model according to the invention is more viable for different types of sensors that can be applied in future products (because of better fidelity to the linear image formation model). In the current approach, the following steps and algorithms of the image reconstruction chain benefit from the increased resolution and contrast of solution.  
         [0020]     Applying the image restoration as a pre-processing operation may minimize non-linearities that are accumulated in the image capturing process. The invention also may prevent over-amplification of colour information.  
         [0021]     The invention can also be applied for restoration of video.  
     
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0022]     The invention is illustrated with reference to examples in accompanying drawings and following description.  
         [0023]      FIG. 1  illustrates an example of the system according to the invention,  
         [0024]      FIG. 2  illustrates another example of the system according to the invention,  
         [0025]      FIG. 3  illustrates an example of a device according to the invention, and  
         [0026]      FIG. 4  illustrates an example of an arrangement according to the invention. 
     
    
     DETAILED DESCRIPTION OF THE INVENTION  
       [0027]     The description of the restoration of images according to the invention can be targeted to three main points, wherein at first the blur degradation function is determined, e.g. by measuring a point-spread function (PSF) for at least one raw colour component. Secondly, a restoration algorithm is designed for at least one raw colour component. Thirdly, a regularization mechanism can be integrated to moderate the effect of high pass filtering. In the description the optics in mobile devices are used as an example, because they may generally be limited to a wide focus range. It will, however, be apparent to the man skilled in the art, that the mobile devices are not the only suitable devices. For example the invention can be utilized by digital cameras, web cameras or similar devices, as well as by high end applications. The aim of this algorithm is to undo or attenuate a degradation process (blurring) resulting from the optics. Due to the algorithm the resulting images becomes sharper and have an improved resolution.  
         [0028]     Wherever a term “colour component” is used, it relates to various colour systems. The example in this invention is RGB-system (red, green, blue), but a person skilled in the art will appreciate other systems such as HSV (Hue, Saturation, Value) or CMYK (Cyan, Magenta, Yellow, Black) etc.  
         [0029]     The image model in the spatial domain can be described as: 
 
 g   i ( m,n )= h   i ( u,v )* f   i ( m,n )+ n   i ( m,n )   (1) 
 
 where g i  is a measured colour component image, f i  is an original colour component, h i  is a corresponding linear blurring in the colour component and n i  is an additive noise term. g i , f i , n i  are defined over an array of pixels (m, n) spanning the image area, whereas h i  is defined on the pixels (u, v) spanning blurring (point-spread function) support. The index i={1, 2, 3, 4} denotes respectively the data concerning colour components, such as red, green 1, blue and green 2 colour components. The invention is described in more detail by means of  FIGS. 1 and 2  each illustrating a block diagram of the image restoration system according to the invention. 
 
 Blur Specification 
 
         [0030]     The procedure for estimating the degradation ( FIG. 1, 110 ) in the image that has been captured by an optical element ( 100 ) is described next. As can be seen in  FIG. 2 , the degradation can be estimated by means of the point-spread function  210  corresponding to the blur in three colour channels (in this example R, G, B) (raw data). The point-spread functions are used to show different characteristics for each colour channel. The point-spread function is an important criterion that can be used to evaluate the performance of imaging systems.  
         [0031]     The point-spread function changes as a function of the wavelength and the position in the camera field of view. Because of that, finding a good point-spread function may be difficult. In the description an out-of-focus close range imaging and a space invariant blurring are assumed. The practical procedure for estimating the point-spread function (h i ) that is associated with each colour component, can also be used as stand-alone application to help in the evaluation process of camera systems.  
         [0032]     Given a blurred image corresponding to one colour component of a checker-board pattern, the four outer corner points are located manually, and first a rough estimate of the corner positions is determined. The exact locations (at subpixel accuracy) are recalculated again by refining the search within a square window of e.g. 10×10 pixels. Using those corner points, an approximation for the original grid image f i  can be reconstructed by averaging the central parts of each square and by asserting a constant luminance value to those squares.  
         [0033]     The point-spread function is assumed to be space invariant, whereby the blur can be calculated through a pseudo-inverse filtering method (e.g. in Fourier domain). Since the pseudo-inverse technique is quite sensitive to noise, a frequency low-pass filter can be used to limit the noise and the procedure can be applied with several images to obtain an average estimate of the point-spread function. (The normalized cut-off frequency of the mentioned low pass filter is around 0.6, but at least any value from 0.4 to 0.9 may be applicable).  
         [0034]     In order to quantify the extent of blur that occurs with each colour channel, a simple statistics is defined, which statistics is determined as a mean of the weighted distance from the centre of the function (in pixels), said weight corresponding to the value of the normalized point-spread function at that point:  
                 S   psf     ⁡     (     h   i     )       =           M   1     ⁢     N   1           ∑     m   ,   n       ⁢       h   i     ⁡     (     m   ,   n     )           ⁢       ∑     m   =   0       M   1       ⁢       ∑     n   =   0       N   1       ⁢       (         m   2     +     n   2         )     ⁢       h   i     ⁡     (     m   ,   n     )                       (   2   )             
 
 wherein M 1  and N 1  are the support of the point-spread function filter. S psf  describes the extent of the blurring. Experiments confirm that the channels have different blurring patterns. For example when studying Mirage-1 camera, the obtained S psf  values were:  
           S   psf     ⁡     (     h   i     )       =     {           5   ⁢     ,     ⁢   42           i   =   1               ⁢     (   red   )                 5   ⁢     ,     ⁢   01           i   =   2               ⁢     (   green   )                 4   ⁢     ,     ⁢   46           i   =   3           (   blue   )                 
 
         [0035]     It can be seen from the results, that the red component was most blurred and noisy, whereby the least blurred was the blue component, which also had the least contrast.  
         [0000]     Restoration Algorithm  
         [0036]     The data concerning colour components is measured by a sensor  120  e.g. by Bayer sensor  220  (in  FIG. 2 ), like a CMOS or CCD sensor. The colour component can be red (R), green  1  (G 1 ) blue (B) and green  2  (G 2 ) colour components as illustrated in  FIG. 2 . Each of these colour “images” is quarter size of the final output image.  
         [0037]     The second image model is provided for to be restored ( 130 ;  250 ). The images are arranged lexicographically into vectors, and the point-spread function h i  is arranged into a block-Toeplitz circulant matrix H i . The second image model is then expressed as: 
 
 {overscore (g)}   i   =H   i   {overscore (ƒ)}   i   +{overscore (η)}   i    (3) 
 
         [0038]     Having a reasonable approximation of H i  the purpose of image restoration is to recover the best estimate {overscore (ƒ)} i  from the degraded observation {overscore (g)} i . The blurring function H i  is non-invertible (it is already defined on a limited support, so its inverse will have infinite support), so a direct inverse solution is not possible. The classical direct approach to solving the problem considers minimizing the energy between input and simulated re-blurred image, this is given by the norm: 
 
 J   LS   =∥{overscore (g)}   i   −H   i   {overscore ({circumflex over (ƒ)})}   i ∥ 2    (4) 
 
 thus providing a least squares fit to the data. The minimization of the norm also leads to the solution of the maximum-likelihood, when the noise is known to be Gaussian. It also leads to the generalized inverse filter, which is given by: 
 
( H   T   H ) {overscore ({circumflex over (ƒ)})}   i   =H   T   {overscore (g)}   i   (5) 
 
         [0039]     In order to solve for this, it is common to use deterministic iterative techniques with the method of successive approximations, which leads to following iteration:  
                     f   _     ^     i     (   0   )       =     μ   ⁢           ⁢     H   T     ⁢       g   _     i         ⁢     
     ⁢           f   _     ^     i     (     k   +   1     )       =           f   _     ^     i     (   k   )       +     μ   ⁢           ⁢       H   T     (         g   _     i     -         f   _     ^     i     (   k   )         )                   (   6   )             
 
 This iteration converges, if  
         0   &lt;   μ   &lt;     2          λ   max              ,       
 
 where λ max  is the largest eigenvalue of the matrix H T H. The iteration continues until the normalized change in energy becomes quite small. 
 
         [0040]     It can be seen from  FIGS. 1 and 2  that the restoration ( 130 ;  250 ) is made separately for each of the colour components R, G, B.  
         [0041]     The main advantages of iterative techniques are that there is no need to explicitly implement the inverse of the blurring operator and that the restoration process could be monitored as it progresses.  
         [0042]     The last squares can be extended to classical least squares (CLS) technique. When spoken theoretically, the problem of image restoration is ill-posed, i.e. a small perturbation in the output, for example noise, can result in an unbounded perturbation of the direct least squares solution that is presented above. For this reason, the constrained least squares method is usually considered in the literatures. These algorithms minimize the term in equation (4) subject to the (smoothness) regularization term, which consists of a high-pass filtered version of the output. The regularization term permits the inclusion of prior information about the image.  
         [0000]     Regularization Mechanism  
         [0043]     In practise, the image sensor electronics, such as CCD and CMOS sensors, may introduce non-linearities to the image, of which the saturation is one of the most serious. Due to non-linearities unaccounted for in the image formation model, the separate processing of the colour channels might result in serious false colouring around the edges. Hence the invention introduces an improved regularization mechanism ( FIG. 2 ;  240 ) to be applied to restoration. The pixel areas being saturated or under-exposed are used to devise a smoothly varying coefficient that moderates the effect of high-pass filtering in the surrounding areas. The formulation of the image acquisition process is invariably assumed to be a linear one (1). Due to the sensitivity difference of the three colour channels, and fuzzy exposure controls, pixel saturation can happen incoherently in each of the colour channels. The separate channel restoration near those saturated areas results in over-amplification in that colour component alone, thus creating artificial colour mismatch and false colouring near those regions. To avoid this, a regularization mechanism according to the invention is proposed. The regularization mechanism is integrated in the iterative solution of equation (6). The idea is to spatially adapt μ in order to limit the restoration effect near saturated areas. The adapted step size is given as follows: 
 
μ adap ( m,n )=β sat ( u, m )μ  (9) 
 
 where μ is the global step-size as discussed earlier, and β sat  is the local saturation control that modulates the step size. β sat  is obtained using the following algorithm: 
        for each colour channel image g i , i={1 . . . 4},     consider the values of the window (w x w ) surrounding the pixel location g i (m, n),     count the number of saturated pixels S i (m,n) in that window.     The saturation control is given by the following equation: 
 
β sat (m, n)=max(0,( w   2 −Σ i=1   4   S   i ( m, n ))/ w   2 ). 
 
 β sat  varies between 0 and 1 depending on the number of saturated pixels in any of the colour channels. 
 
 Image Reconstruction Chain 
       
 
         [0048]     The previous description of the restoration of each of the colour component is applied as the first operation in the image reconstruction chain. The other operations ( 140 ,  260 ) will follow such as for example Automatic White Balance, Colour Filter Array Interpolation (CFAI), Colour gamut conversion, Geometrical distortion and shading correction, Noise reduction, Sharpening. It will be appreciated that the final image quality ( 270 ) may depend on the effective and optimized use of all these operations in the reconstruction chain. One of the most effective implementations of the image reconstruction algorithms are non-linear. In  FIG. 1  the image processing continues e.g. with image compression ( 150 ) or/and downsampling/dithering ( 160 ) process. Image can be viewed ( 180 ) by camera viewfinder or display or be stored ( 170 ) in compressed form in the memory.  
         [0049]     The use of restoration as the first operation in the reconstruction chain ensures the best fidelity to be assumed linear imaging model. The following algorithms, especially the colour filter array interpolation and the noise reduction algorithms act as an additional regularization mechanism to prevent over amplification due to excessive restoration.  
         [0000]     Implementation  
         [0050]     The system according to the invention can be arranged into a device such as a mobile terminal, a web cam, a digital camera or other digital device for imaging. The system can be a part of digital signal processing in camera module to be installed into one of said devices. One example of the device is an imaging mobile terminal as illustrated as a simplified block chart in  FIG. 3 . The device  300  comprises optics  310  or a similar device for capturing images that can operatively communicate with the optics or a digital camera for capturing images. The device  300  can also comprise a communication means  320  having a transmitter  321  and a receiver  322 . There can also be other communicating means  380  having a transmitter  381  and a receiver  382 . The first communicating means  320  can be adapted for telecommunication and the other communicating means  380  can be a kind of short-range communicating means, such as a Bluetooth™ system, a WLAN system (Wireless Local Area Network) or other system which suits local use and for communicating with another device. The device  300  according to the  FIG. 3  also comprises a display  340  for displaying visual information. In addition the device  300  comprises a keypad  350  for inputting data, for controlling the image capturing process etc. The device  300  can also comprise audio means  360 , such as an earphone  361  and a microphone  362  and optionally a codec for coding (and decoding, if needed) the audio information. The device  300  also comprises a control unit  330  for controlling functions in the device  300 , such as the restoration algorithm according to the invention. The control unit  330  may comprise one or more processors (CPU, DSP). The device further comprises memory  370  for storing data, programs etc.  
         [0051]     The imaging module according to the invention comprises imaging optics and image sensor and means for finding degradation information of each colour component and using said degradation information for determining a degradation function, and further means for restoring said each colour component by said degradation function. This imaging module can be arranged into the device being described previously. The imaging module can be also arranged into a stand-alone device  410 , as illustrated in  FIG. 4 , communicating with an imaging device  400  and with a displaying device, which displaying device can be also said imaging device  400  or some other device, like a personal computer. Said stand-alone device  410  comprises a restoration module  411  and optionally other imaging module  412  and it can be used for image reconstruction independently. The communication between the imaging device  400  and the stand-alone device  410  can be handled by a wired or wireless network. Examples of such networks are Internet, WLAN, Bluetooth, etc.  
         [0052]     The foregoing detailed description is provided for clearness of understanding only, and not necessarily limitation should be read therefrom into the claims herein.
This invention relates to a method for improving image quality of a digital image captured with an imaging module comprising at least imaging optics and an image sensor, where the image is formed through the imaging optics, the image consisting of at least one colour component. In the method degradation information of each colour component of the image is found and is used for obtaining a degradation function. Each colour component is restored by said degradation function. The image is unprocessed image data, and the degradation information of each colour component can be found by a point-spread function. The invention also relates to a device, to a module, to a system and to a computer program product and to a program module.