Color image normalization

Normalization in image processing at all, is a process of range expansion of  the values of the pixel intensity. The "image normalization" as a term , is often faced in the Digital Signal Processing, Maths etc. You can read more about the image normalization here. The main idea here is that if we have poor range values and we need wider value range, we can expand it via simple math. However the basic aim of this post is to present the "color normalization". Unlike the common image normalization, the color image normalization is intended to compensate the distribution of color values in an image depending on the illumination - - which may vary i.e. depending on different lighting conditions or different camerasThese two terms sound very similar and many people can be confused. Moreover, it will be hard to note the distinction if you have not got clear idea for the purposes of your project. This post is intended to present the  "color normalization" and to propose exemplary code. There is a diversity of approaches for color image normalization. The math in every one of them is different also. Assuming a linear camera response, if light intensity is scaled by a factor "s" then the image scales by the same factor each captured (r; g; b) pixel becomes (sr; sg; sb). Relative to this simple physical model it is easy to derive a normalization procedure which is independent of the intensity of the viewing illuminant:


r/(r + g + b)
g/(r + g + b)
b/(r + g + b);

The normalization shown is well used and well accepted in the computer vision and does an admirable job of rendering image colors independent of the power of the viewing illuminant. I will present you some simple method in M-code. It is different from the shown above. There is brief explanation in the comment of the code.


function [NormalizedImage]=ImageNormalisation(img)
%Normalising RGB Image
%[NormalizedImage]=ImageNormalisation(img)
%img - RGB image of UINT8 type
%NormalizedImage - output image of type UINT8 represented as RGB again
%converting an RGB image into normalized RGB removes the effect of any
%intensity variations.
%R'=R*sqrt(3)/sqrt(R^2 + G^2 + B^2);
%G'=G*sqrt(3)/sqrt(R^2 + G^2 + B^2);
%B'=B*sqrt(3)/sqrt(R^2 + G^2 + B^2);
%If black and R=B=G=0 then R'=G'=B'=1/sqrt(3);

[ImSizeY ImSizeX ImSizeZ]=size(img);
img=double(img);
NormalizedImage=zeros(ImSizeY,ImSizeX,ImSizeZ);
for i=1:1:ImSizeX
    for j=1:1:ImSizeY
        R=img(j,i,1);
        G=img(j,i,2);
        B=img(j,i,3);
        if ((R+G+B)>0)
            NormalizedImage(j,i,1)=R/sqrt(R^2+G^2+B^2);
            NormalizedImage(j,i,2)=G/sqrt(R^2+G^2+B^2);
            NormalizedImage(j,i,3)=B/sqrt(R^2+G^2+B^2);
        else
            NormalizedImage(j,i,1)=1/sqrt(3);
            NormalizedImage(j,i,2)=1/sqrt(3);
            NormalizedImage(j,i,3)=1/sqrt(3);
        end
    end
end
NormalizedImage=NormalizedImage*255;
NormalizedImage=uint8(NormalizedImage);

Here is an image used to test the code:


Source image

And here is the result of color normalization:

Result image

It is noticeable that in the result image there is no such illumination differences as in the original image and the colors of the objects are more homogenous.


Няма коментари:

Публикуване на коментар