Click here to Skip to main content
15,893,622 members
Articles / Multimedia / GDI+

Image Processing: Skin Detection, Some Filters and EXIF Tags

Rate me:
Please Sign up or sign in to vote.
4.93/5 (19 votes)
17 Jul 2009CPOL2 min read 88.2K   6K   84  
Simple algorithms of skin detection and some useful filters
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace RedMatter
{
        /// <summary>
        /// Class for building binary image.
        /// </summary>
        public class BinarySelector
        {
            /// <summary>
            /// Source image.
            /// </summary>
            private Bitmap sourceImage;

            public Bitmap SourceImage
            {
                get { return sourceImage; }
                set { sourceImage = value; }
            }

            /// <summary>
            /// Selection method;
            /// </summary>
            private IImageSelector selector;

            public IImageSelector Selector
            {
                get { return selector; }
                set { selector = value; }
            }

            /// <summary>
            /// Color for background of selection.
            /// </summary>
            private Color firstColor = Color.Black;

            public Color FirstColor
            {
                get { return firstColor; }
                set { firstColor = value; }
            }

            /// <summary>
            /// Color for select image.
            /// </summary>
            private Color secondColor = Color.White;

            public Color SecondColor
            {
              get { return secondColor; }
              set { secondColor = value; }
            }

            /// <summary>
            /// Building selection image.
            /// </summary>
            public Bitmap SelectImage
            {
                get
                {
                    Bitmap bmp = new Bitmap(sourceImage);
                    for (int i = 0; i < bmp.Width; i++)
                    {
                        for (int j = 0; j < bmp.Height; j++)
                        {
                            Color pixel = bmp.GetPixel(i, j);
                            if (selector.IsSelectedPoint(pixel) == true)
                            {
                                bmp.SetPixel(i, j, secondColor);
                            }
                            else
                            {
                                bmp.SetPixel(i, j, firstColor);
                            }
                        }
                    }
                    return bmp;
                }
            }

            #region Constructors

            public BinarySelector(Bitmap bmp)
            {
                this.sourceImage = bmp;
            }

            public BinarySelector(Bitmap bmp, IImageSelector selector)
            {
                this.sourceImage = bmp;
                this.selector = selector;
            }

            #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Russian Federation Russian Federation
Hello! My name is Maxim Subbotin.

Now I work in sphere of web-development. I'm interesting researches in SEO field.
If you interesting, you can see this tool:

KeywordCompetitor

Comments and Discussions