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<Color> ColoursToDetect = new List<Color>()
{
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.