5,442,984 members and growing! (18,733 online)
Email Password   helpLost your password?
General Programming » Algorithms & Recipes » General     Advanced

Photometric Normalisation Algorithms

By mosquets

Pre-processing faces images in order to increase the performance of verification and recognition algorithms
Windows, Visual Studio, Dev

Posted: 14 Nov 2006
Updated: 14 Nov 2006
Views: 16,298
Bookmarked: 10 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
16 votes for this Article.
Popularity: 3.78 Rating: 3.14 out of 5
10 votes, 62.5%
1
0 votes, 0.0%
2
0 votes, 0.0%
3
1 vote, 6.3%
4
5 votes, 31.3%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

Sample Image - normalisation_algorithms.jpg

Output of multiscale retinex algorithm.

Introduction

The variation of illumination conditions of an object can produce large changes in the image plane, significantly impairing the performance of face verification and recognition algorithms. I present three photometric normalisation algorithms for use in pre-processing face images in order to be used in verification and recognition algorithms. Mainly I follow the ideas of paper "A Comparison of Photometric Normalisation Algorithms for Face Verification",James Short, Josef Kittler and Kieron Messer(2004) and "Lighting Normalization Algorithms for Face Verification",Guillaume Heusch ,Fabien Cardinaux, Sebastien Marcel(2005). Multiscale retinex method is coded exactly like the theory say. The anisotropic and isotropic smoothing methods have a little modifications but essentially its are the same. If you want to see more details about them you can see the papers previusly mentionated.

Using the code

You can apply the multiscale retinex method like:
        MultiscaleRetinex retinex = new MultiscaleRetinex(param.Sigmas, param.Widths, param.FilterSize);
        picFiltered.Image = retinex.Apply((Bitmap)bitmap.Clone());
This is the code of multiscale retinex algorithm:
        public override unsafe Bitmap Apply(Bitmap bitmap)
        {
            int count = sigmas.Length;
            Bitmap bmp;
            double[,] sum = new double;
            
            for (int i = 0; i < count;i++ )
            {
                bmp = new GaussianBlur(sigmas[i], size).Apply(bitmap);
                sum = SumBitmap(bmp,sum,widths[i]);
            }
            return Normalise(DivBitmap(bitmap, sum));
        }
You can apply the isotropic smoothing method like:
        IsotropicSmoothing iso = new IsotropicSmoothing(param.Value);
        picFiltered.Image = iso.Apply((Bitmap)bitmap.Clone());
This is the code of isotropic smoothing algorithm:
        public override unsafe Bitmap Apply(Bitmap bitmap)
        {
            Bitmap = bitmap;
            Point size = PixelSize;
            double[,] src = new double[size.X, size.Y];
            bool first = true;
            byte N, S, E, W, A;
            double Lw, Le, Ls, Ln, tmp, min = 0, max = 0;

            LockBitmap();

            for (int y = 0; y < size.Y ; y++)
            {
                PixelData* pPixel = PixelAt(0, y);
                for (int x = 0; x < size.X ; x++)
                {
                    tmp = pPixel->gray;

                    //Applying the process to all pixels of image except to the borders
                    if ((x > 0) && (x < size.X-1) && (y > 0) && (y < size.Y-1))
                    {
                        //Adjacent neighbouring pixels
                        A = pPixel->gray;           //current
                        E = PixelAt(x, y+1)->gray;  //east 
                        S = PixelAt(x+1, y)->gray;  //south 
                        N = PixelAt(x-1, y)->gray;  //north 
                        W = PixelAt(x, y-1)->gray;  //west  

                        //Ld refers to the derivative with respect to 
                        //each of the four adjacent neighbouring pixels
                        Lw = A - W;
                        Le = A - E;
                        Ln = A - N;
                        Ls = A - S;

                        //Isotropic smoothing
                        tmp = A + smooth * (Ln + Ls + Le + Lw);
                    }

                    src[x, y] = tmp;

                    //Computing the min and max values from all pixels of image
                    if (first) { min = max = tmp; first = false; }
                    else
                    {
                        if (tmp < min) min = tmp;
                        else
                            if (tmp > max) max = tmp;
                    }
                    pPixel++;
                }
            }
            UnlockBitmap();
            return Normalise(src, min, max);
        }

Sample Image - example_isotropic.jpg

Output of isotropic smoothing algorithm.

You can apply the anisotropic smoothing method like:
        AnisotropicSmoothing anis = new AnisotropicSmoothing(param.Value);
        picFiltered.Image = anis.Apply((Bitmap)bitmap.Clone()); 
This is the code of anisotropic smoothing algorithm:
        public override unsafe Bitmap Apply(Bitmap bitmap) 
        {
            Bitmap = bitmap;
            Point size = PixelSize;
            double[,] src = new double[size.X,size.Y];
            bool first = true;
            byte N, S, E, W, A;
            double Lw, Le, Ls, Ln, pw, pe, ps, pn, eps = .1, tmp, min = 0, max = 0;
            
            LockBitmap();
            
            for (int y = 0; y < size.Y; y++)
            {
                PixelData* pPixel = PixelAt(0, y);
                for (int x = 0; x < size.X; x++)
                {
                    tmp = pPixel->gray;

                    //Applying the process to all pixels of image except to the borders
                    if ((x > 0) && (x < size.X-1) && (y > 0) && (y < size.Y-1))
                    {
                        //Adjacent neighbouring pixels
                        A = pPixel->gray;           //current
                        E = PixelAt(x, y+1)->gray;  //east 
                        S = PixelAt(x+1, y)->gray;  //south 
                        N = PixelAt(x-1, y)->gray;  //north 
                        W = PixelAt(x, y-1)->gray;  //west  

                        //Ld refers to the derivative with respect to 
                        //each of the four adjacent neighbouring pixels
                        Lw = A - W;
                        Le = A - E;
                        Ln = A - N;
                        Ls = A - S;

                        //Weber’s contrast inverse
                        pw = Math.Min(A, W) / (Math.Abs(A - W) + eps);
                        pe = Math.Min(A, E) / (Math.Abs(A - E) + eps);
                        pn = Math.Min(A, N) / (Math.Abs(A - N) + eps);
                        ps = Math.Min(A, S) / (Math.Abs(A - S) + eps);

                        //Anisotropic smoothing
                        tmp = A + smooth * (Ln * pn + Ls * ps + Le * pe + Lw * pw);
                    }

                    src[x, y] = tmp;

                    //Computing the min and max values from all pixels of image
                    if (first) { min = max = tmp; first = false; }
                    else
                    {
                        if (tmp < min) min = tmp;
                        else
                            if (tmp > max) max = tmp;
                    }
                    pPixel++;
                }
            }
            UnlockBitmap();
            return Normalise(src,min, max);
        }

Sample Image - example_anisotropic.jpg

Output of anisotropic smoothing algorithm.

Versions

1.0 14 Nov 2006

Credits

  • Dr. Eduardo Garea(Adviser)
  • Dr. Edel García(Adviser)
  • Andrew Kirillov's Image Processing Lab in C#
  • Points of interest

    Image Processing in general (filtering,enhancement,denoisy etc.),C#, ASP.NET, Matlab, Java.

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    About the Author

    mosquets



    Occupation: Web Developer
    Location: Cuba Cuba

    Other popular Algorithms & Recipes articles:

    Article Top
    Sign Up to vote for this article
    You must Sign In to use this message board.
    FAQ FAQ Noise ToleranceSearch Search Messages 
     Layout  Per page   
     Msgs 1 to 8 of 8 (Total in Forum: 8) (Refresh)FirstPrevNext
    Subject  Author Date 
    GeneralBit color without loose face detailsmemberAriston Darmayuda8:26 22 Mar '07  
    GeneralRe: Bit color without loose face detailsstaffChristian Graus8:37 22 Mar '07  
    GeneralRe: Bit color without loose face detailsmembermosquets10:51 22 Mar '07  
    GeneralRe: Bit color without loose face detailsmemberAriston Darmayuda4:42 25 Mar '07  
    GeneralColor Imagememberjapacheco11:43 22 Jan '07  
    GeneralRe: Color Imagemembermosquets5:05 23 Jan '07  
    GeneralHow can I enhance the original image by the output of Multi Scale Retinex?memberBrian Lau20:54 3 Dec '06  
    AnswerRe: How can I enhance the original image by the output of Multi Scale Retinex?membermosquets5:17 4 Dec '06  

    General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    PermaLink | Privacy | Terms of Use
    Last Updated: 14 Nov 2006
    Editor:
    Copyright 2006 by mosquets
    Everything else Copyright © CodeProject, 1999-2008
    Web10 | Advertise on the Code Project