Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
571 views
in Technique[技术] by (71.8m points)

image processing - C# - Black points recognition from a photo

I have some photos of white pages with some black points drawn on, like this: photo (the points aren't very circular, I can draw them better), and I would find the coordinates of these points. I can binarize the images (the previous photo binarized: image), but how can I find the coordinates of these black points? I need only the coordinates of one pixel for each point, the approximate center.

This is for a school assignment.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Since its for school work I will only provide you with a high level algorithm.

Since the background is guarantee to be white, you are in luck.

First you need to define a threshold on the level black which you want to consider as the black dot's color.

#ffffff is pure white and #000000 is pure black. I would suggest some where like #383838 to be your threshold.

Then you make a two dimensional bool array to keep track of which pixel you have visited already.

Now we can start looking at the picture.

You read the pixel one at the time horizontally and see if the pixel is > threshold. If yes then you do a DFS or BFS to find the entire area where the pixel's neighbor is also > threshold.

During the process you will be marking the bool array we created earlier to indicate that you have already visited the pixel.

since its a circle point you can just take the min, max of x and y coordinate and calculate the center point.

Once you are done with one point you would keep looping thru the picture's pixel and find the points that you have not visited (false in the bool array)

Since the points you have on the photo contains some small dots on the edge which is not connected to the large point, you might have to do some math to see if the radius is > some number to consider that a valid point. Or instead of a radius 1 neighbor you do a 5 - 10 pixel neighbor BFS/DFS to include the ones that are really close to the main point.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...