I have 3 black dots in a scanned image that its size is 600x400 px, and I like to know the best and simple way in C# to get their coordinates, like this:
dot1 X=400px Y=100px
dot2 X=100px Y=200px
dot3 X=300px Y=300px
I have 3 black dots in a scanned image that its size is 600x400 px, and I like to know the best and simple way in C# to get their coordinates, like this:
dot1 X=400px Y=100px
dot2 X=100px Y=200px
dot3 X=300px Y=300px
I will take a long shot and assume that you only have two colors exactly as the image shows: Black dots and White background.
You may work around that and detect the occurrence of the black color, something like this as a start for your algorithm:
int HEIGHT = 400;
int WIDTH = 600;
// get the jpg image
Bitmap bitmap;
using(Stream bmpStream = System.IO.File.Open(fileName, System.IO.FileMode.Open )){
Image image = Image.FromStream(bmpStream);
bitmap = new Bitmap(image);
}
for (int x = 0; x < HEIGHT; x++){
for (int y = 0; y < WIDTH; y++){
Color pixelColor = bitmap.GetPixel(x, y);
// check if it's black or a shade of black
// e.g. if it belongs to an array of colors..etc
// if so, record the coordinates (x,y)
}
}