c# - What is a fast way to find all circle sizes? -
given black , white picture (so colors black or white no shades of grays), there lot of different sizes circles on (in black), fast way find center coordinate of circles , sizes of circles , store them dictionary entry? when mean fast mean if call circle finding function 10 or 20 times per second wouldn't lag much. did researching , found out find center of circle or radius taking 3 points on circle, can help?
the first thing comes mind scan image pixel pixel, looking black pixels. when find one, start flood filling. once flood fill finishes measure left, right, top, , bottom extents, derive center point dividing 2. assumes none of circles overlap. i'm sure there more optimized methods may avoid flooding entire circle.
optimization #1: instead of flood filling, when find first black pixel, adjacent pixels along 8 neighbors have @ least 1 white neighbor. continue following pixels until hit first pixel again. should give outline, there can derive width, height, , center point same way in original answer.
optimization #2: if circles have minimum size don't have scan pixel pixel. can scan horizontal , vertical lines spaced minimum size looking black pixels.
Comments
Post a Comment