C#: Detecting All Shades Of Violet [closed]
G'day, I'm trying to detect if an image has any shades of Violet in it.
I made this in C# however, after some research, I came across this library and was wondering if it could help to improve what I already have?
I did see that it can detect a Red stop sign, but what about all the different shades of red?
private bool Process(Image image)
{
using (Bitmap bitmap = new Bitmap(image))
{
int infected = 0;
int total = 0;
LockBitmap lockBitmap = new LockBitmap(bitmap);
lockBitmap.LockBits();
for (int x = 0; x != lockBitmap.Width; x++)
{
for (int y = 0; y != lockBitmap.Height; y++)
{
if (lockBitmap.GetPixel(x, y).GetHue() + 25 > Color.FromKnownColor(KnownColor.Violet).GetHue() + 20) //need to fine tune.
{
infected++;
}
total++;
}
}
lockBitmap.UnlockBits();
Console.WriteLine(infected.ToString());
Console.WriteLine(total.ToString());
if (infected > 450) //need to fine tune.
{
MessageBox.Show("Damaged");
return true;
}
else
{
MessageBox.Show("Not Damaged");
return false;
}
}
}
Here are some of the images I'm working with.
<-- This image as far as I can tell detects the violet colour(s)
<-- This one does too
This one does too, which seems pretty weird because unless my eyes need checking, I cant see any violet.
This one doesn't detect any violet.
What can I do to make sure that it only detects violet (any shade of violet) that we humans can see?
Thanks in advanced.
sorry, but we cannot help you with it, since it is not related to opencv at all.
actually, abi, I was looking for a method that OpenCV might have and or if it was capable of doing so
there is no support for c#, either.
but usually, you'd filter a hsv range using inRange()