Click to See Complete Forum and Search --> : Approach for vector- raster conversion and vice-versa


bhartinder
November 20th, 2002, 12:24 AM
Hello everybody,
I want to know about the approaches to be followed for vector to raster and raster to vector formats conversions.
Is anybody aware of approaches/algorithms of doing this?

galathaea
November 20th, 2002, 01:15 AM
There is an advanced area of mathematics that deals particularly with this issue, and there a four basic methods of attacking the problem. All of the methods deal with the fundamental problem of object classification. The first, and most restricted method, uses group theory and transformation groups on an image to deduce a decomposition/classification into objects. The second method uses basic topology (mostly homotopy) of the image to define regions/edges and make the deduction. The third method uses a general category theory of shapes that classifies objects based upon their mapping properties. And finally, neural networks and adaptive learning models have probably been the most successful for producing "algorithms" (or networks) that can take an image and correctly identify objects.

In many simple images, the first or second methods are easiest and fastest to implement. However, for complicated real-world vision projects, the latter two provide the greatest flexibility.

This is the basic problem of what you have asked. Because vector graphics represent their displays in terms of objects, whereas raster represents image planes.

Amn
November 24th, 2002, 10:21 AM
I happen to have done quite a bit of work in vector->raster algorithms. This involves rasterizing lines, ellipses, polygons etc.
I will be posting an article on fast line rasterizing, if you are around perhaps you could take a look at it.

When it comes to raster->vector, thats a quite complicated area of research, as practically information is transferred from one domain to another, thus it is being transformed under way, so that in its target form it is completely different, than in source form. These kind of operations require artificial intelligence to kick in, as the loss of information in some of its forms is hard to recover and rebuild without some intelligence involved.

Galathea explains this much better than me, and he already has started with neuronets and patter recognition. I hope he will give you more insight there ;)

Aztral
November 28th, 2002, 05:56 PM
Vector to raster is no biggie...just render the vector image
on to a DC, and grab the bits off the DC.

A very simple approach to raster to vector would be sort of
how RLL compression works. Grab the bits of the raster image,
and starting with the pixel 0,0 get it's color. Continue looking at
pixels (preferably horizontally) until a new color is encountered.
Now just add a command to the vector file which creates a line
from pixel 0,0 to the pixel of a different color (not including).

Now repeat the process for the whole raster file. You'll end with
a file containing a series of line commands.

That's about the simplest raster to vector conversion I can think of.

Yves M
November 28th, 2002, 06:11 PM
Yes, but it would be useless for identifying a single vertical line :p

Aztral
November 28th, 2002, 06:19 PM
Hiyaz,

What I was suggesting is to break up a raster into a SERIES of
lines. The approach would work OK on a file which doesnt have much color change ( or where some loss of color in a file with a lot
of change was acceptable ).

For a better solution use the lines created in step one, and use
the end points to create regions, then you could replace a number
of line commands into a single drawregion command.

Anyways,
Aztral

galathaea
November 29th, 2002, 02:25 AM
I understand what you are saying, Aztral, and to be honest, you are the first to give a clear answer to the second part of the original post. However, it is not always the case that all that is wanted is a format conversion. Often, one wants the objects in the vector conversion of the raster to identify the actual objects as our language defines them from the picture. This is the case, for example, when one is working on forensic analysis of film or automatic image decomposition for artisitic composition packages. Your second response comes close to the homotopy approach, however it would still fail to connect diagonal lines that do not connect vertically or horizontally.

I'm not opposed to your solution, if all the original poster wants is a method of converting so they can view their image in a vector display algorithm. I'm just pointing out that this method won't allow the manipulations sometimes expected by the use of vector graphics programs...

Peace