I’m trying to generate a vector graphic from an area in a bitmap image, and while my current algorithm works for most cases it has some problems and it is quite slow.
So I was wondering if you people know of any simple algorithms or code examples of how to do this efficiently.
My situation is simple. I have a bitmap image, with several flat uniform areas. I wish to convert these areas into sets of points that I can use to recreate them later as vector graphics. I will never have overlapping shapes, the shapes are always enclosed and they are always of one color (the same RGB value for all pixels) so it is quite easy to determine the outline, but doing efficiently is harder.
EDIT: I pressed the submit button too soon…
Ideally I would like a solution working in .NET, but pseudo code should also work well. Maybe you folks know of some good resources on image manipulation?
EDIT again: So what I am after is an algorithm or a library that will give me a list of points or vectors that describe each area in the image, not the vectorized image itself.
Since your objects are distinct, you can run an algorithm for connected component labeling. The wikipedia article is just OK as a start, though I won’t know why they concentrate on multi-pass algorithms, one pass works easily enough. While you discover the connected components, you’ll have to maintain some data structure to represent the outline. If your objects are known to be simple (e.g. rectangles at normal angles from the axes, or circles) then the representation may be very simple. If they are general shapes, then you’ll need some more complex curve representation. (Keep in mind tricky objects like ‘U’ or ‘O’ shapes.)