graphics - Algorithm to find the coordinates of a corner in a simple image -
i have bitmap 2 large blocks of colors intersect, , find intersection of these 2 blocks.

note not know actual geometry of 2 shapes, because raw pixel data.
is there algorithm use this?
if have pixel data in memory (which i'd assume do, major sticking point) , there 2 distinct colours, should need run horizontal scanline find point rgb changes colour x colour y (note may need run scanline few times, in case it's no worse o(height)).
simple graph traversal (bfs or dfs) continue walk down line (you should need 3 points , you'll able form geometric line equation a*x + b*y + c = 0 (assuming it's not curve)).
repeat scanline vertically (again, worst case it's o(width)). find 3 points , you'll have 2 lines d*x + e*y + f = 0. using little bit of comp. geom, intersection of these 2 lines give point.
Comments
Post a Comment