Detecting a certain amount of violet in an image I need to be able to detect if an image has the colour Violet in it. (Follow-up)

The problem that I'm facing is that there are quite a number of shades of violet that it seems almost impossible it add every single one.

 private void ProcessImage(PictureBox picture)
    {
        using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
        {
            List&lt;Color&gt; ColoursToDetect = new List&lt;Color&gt;()
            {
                Color.FromArgb(202,156,254),
                Color.FromArgb(143,125,151),
                Color.FromArgb(100,76,136),
                Color.FromArgb(232,175,254)
            };
            Boolean colour_Found = false;
            Bitmap SelectedImage = new Bitmap(picture.Image);
            Color selected_Pixel;

            for (int x = 0; x != SelectedImage.Width; x++)
            {
                for (int y = 0; y != SelectedImage.Height; y++)
                {
                    selected_Pixel = SelectedImage.GetPixel(x, y);
                    foreach (Color c in ColoursToDetect)
                    {
                        if (c == selected_Pixel)
                        {
                            colour_Found = true;
                            MessageBox.Show("Found");
                            colour_Found = true;
                        }
                    }
                    if (colour_Found)
                    {
                        break;
                    }
                }
            }
        }
    }


The above code is working (So to speak) However I'm worried that one day an image will have a certain violet that i have no added and in hindsight will make the code useless.I did look at the .Net library AForge http://www.aforgenet.com/projects/iplab/, However I couldn't find any information about detecting a range of a certain colour.
Try using HSV/HSL to represent color instead of RGB.

You can then define violet as some hue range, e.g. 250° to 310° and similarly for saturation and lightness/value.



Always use a using when you have tempoary disposable resources like a Bitmap



Variables in C# are camelCase:

Boolean colourFound = false;
Bitmap selectedImage = new Bitmap(picture.Image);
Color selectedPixel;




Try to limit the scope of variables, move the declaration of selectedPixel to where you currently assign it.