Pergunta

I have generated set of points, that create polygonal areas border. On image below, there is an example of what I mean. The black "spots" should not be there and line should be "clear". I need to remove those points.

enter image description here

Now the problem is double. First, I dont know, how this situation is called. Its not aliasing or jagged edge, because those points are not obtained from line generating algorithm, but from contour generator. And if not the name, than at least some push, how to solve this, would help me.

So far, I have tried convert this to chain code and simplify it, but that didn´t worked very well and it was rather slow. Convert those dots to geometry and use Ramer algorithm to simplify geometry works better, but it destroy some "fine" detail, that should be there.

Foi útil?

Solução 2

Separate the contour curves and clean each one by itself.

For each contour:

  1. If the curve is not closed, close it with a temporary line.
  2. Flood-fill the contour curve to get a solid monochrome figure.
  3. Run contour detection on the result. The edge of a monochrome figure will be a clean line.
  4. Flood-fill the area outside the new contour curve.
  5. Run contour detection one last time to restore the original contour.

Re-assemble the contours into a single bitmap.

Outras dicas

You can try the following:

First search for these spots. From your figure it seems that the spots look something like the following:

1 1
1 1

That is, a square matrix of colored pixels. Such spots can easily be found by traversing the pixel matrix once.

Now once you identify these spots, you will need to check for the neighbouring pixels and see what pattern is the curve/line following and accordingly delete the unnecessary pixels.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top