LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Vectorize an image using Labview

Solved!
Go to solution

@VGans wrote:

 

 

BTW: what we're supposed to vectorize are scanned drawings made by children 😉


That could make the process a little easier as the images are presumably simple blocks of colour.

 

Unfortunately, my colleague doesn't have the code anymore, but suspects the image processing part used the Vision Development Module, we'll have to wait to see if he comes up with anything more.

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 11 of 25
(1,059 Views)

Hi VGans,

 

As Thoric mentioned, some of the guys here at NI UK built up a demo to take in a bmp image and analyse where the edges were and then feed the coordinates down to a Compact RIO in order to control stepper motors and draw the image on an Etch-A-Sketch. I've managed to dig the code out from our server here, and have just been looking at the code. Unfortunately the code isn't going to be a direct help to you as it is using Vision Development Module again, and I can see from your previous posts that you're on Mac OS so VDM isn't supported.

 

I can give you the steps in the algorithm though which may help you build your own solution.

 

First step is to analyse the image for particles, and then iterate around a For Loop once for each particle in the image.

We then use thresholding to mask of each particle in turn, and use the coordinates to get the edges of each particle, which correspond to the edges of items in the actual image.

These coordinate sets are then built into an array of line coordinates which are passed out of the vi.

 

I hope that makes sense and helps your understanding. 

 

Best regards,

 

Pete H - NI UK

0 Kudos
Message 12 of 25
(1,055 Views)

Hello VGans,

 

Can you post an example of such a typical picture/bitmap?

 

Based on the first post I had assumed that it was a single color line based bitmap.

Which could (sometimes) be relatively simple as you can properly detect the edges.

 

However (as Peter correctly noted) you would first have to identify the particles and afterwards detect the edges related to those particles.

For the second part you could use an edge detection method.

 

Personally I have only done something similar (in LabVIEW) with the IMAQ VIs

In other languages I have done this from scratch (more than 5 years ago) and it was indeed not that easy.

Do let the fora know if there's a specific part where you get stuck. 

 

PS: I shouldn't have oversimplified the effort required to implement this.
After seeing Germany's win yesterday my mind seems to be thinking today that everything is easy. 😉

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 13 of 25
(1,042 Views)

Hi Pete,

 

Thanks for the help! We're going to try to apply what you explained!

 

@Thierry, right now, we are trying to vectorize a black and white image (not even a greyscale), then, if it works, we'll try to apply it to simple images with some colors (like red, green and blue) and then maybe we'll try to make it work for a bit more complicated pictures.

 

Because it's supposed to be for kids (the main idea is to make something like an app where kids can draw something and that can send the picture to the machine that will then carve it into a piece of wood. The colors are then represented by different depths), the images will probably be very simple.

The only thing we're missing is a way to transform the drawings into a set of "lines" that the machine can follow to carve the drawing. That's why we were thinking about vectorization. But it looks like edge detection is maybe best.

 

Anyway, we'll be trying both if one does'nt work! But it's surely going to take some time!

 

 

 

PS: in attachment is the kind of picture we're hoping to carve

 

 

Edit: I forgot to mention that we were thinking about changing the colored pictures in greyscale before vectorizing. Do you think it could make it easier?

 

 

0 Kudos
Message 14 of 25
(1,030 Views)

Hello VGans,

 

I'm going to try to now take a bit more application oriented approach to try to fully understand what you need, before making any it advise/conclusions (without too much assumptions).

 

A few more questions to give a better idea of everything:

- Will every color/particle be surrounded by black boundary lines?

  This does not seem to be the case based on the picture. (eg. green line below the flower)

  Will these lines be solid black or can they be any color?

- How do you want to handle objects inside objects? (eg. the eyes inside the head)

- How would you like to handle purely black lines? (like the feet)

- How would you like to handle areas that are not colored, but do have the form/figure pre-defined (head, hair)?

- How would you handle it when people draw with their colors outside of the forms/figures defined by (black) lines? (like in the case of the sun)

- If you go from light green to dark green (or any other gradient): Would you then like to see this result in a difference in depth?

  Or to be a bit more generic: How do you want to handle gradients in color?

- Can we assume that the border of the drawing is completely white?

 

Concerning the workings of  the carving machine:

- Are you at this moment already carving at different depths?

 

Sorry for the overload of questions.

I should have asked these from the beginning, but somehow you have caught me off-guard.

 

PS: What might be the best approach will depend on some of the answers to the questions above. I think that more than just an edge detection will be needed.

 

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 15 of 25
(1,007 Views)

Hi Thierry,

 

 

A few more questions to give a better idea of everything:

- Will every color/particle be surrounded by black boundary lines?

          Not necessarely, because we really want to import drawings that kids made and then carve them into a piece of wood. If the kid draws a black line, the machine is going to carve the same line at a depth of 0.1 cm for example. If the interior of the black line is green, it's gonna carve at a depth of 0.3 for example.

 

- How do you want to handle objects inside objects? (eg. the eyes inside the head)

          Ideally, the whole drawing should be made of lines. For example, the eyes would be small circular lines. By line, I mean that it has a starting point and a end point (and some points between the two if it is not a straight line)

 

- How would you like to handle purely black lines? (like the feet)

          Purely black lines would be handled as any other lines. The machine only reads depths of carving. Therefore, we were thinking about transforming the scanned drawing into a greyscale picture and assign a depth for each "intensity" of grey.

 

- How would you like to handle areas that are not colored, but do have the form/figure pre-defined (head, hair)?

          Again, these would only be seen as a "complex" line for the machine.

 

- How would you handle it when people draw with their colors outside of the forms/figures defined by (black) lines? (like in the case of the sun)

          Considering that the machine only sees lines, I would say that it doesn't show any difference from other lines. If the kid draws a big black filled circle for example, we would like to transform this circle into a long spiral line so that the machine first draws the exterior and then spirals to the center to carve the whole circle.

 

- If you go from light green to dark green (or any other gradient): Would you then like to see this result in a difference in depth?

          We have not really thought about that right now because we are first trying to make the program work for a binary (black and white) picture. But at the end, we would like so. The idea was to transform the picture in a greyscaled picture and then assign a depth to every intensity of grey. Therefore, if this works, we would see a difference between dark green and light green.

- Can we assume that the border of the drawing is completely white?

           Yes

 

Concerning the workings of  the carving machine:

- Are you at this moment already carving at different depths?

           Yes. At the moment, we have an operationnal program where we can draw lines on a sketch. Then, we we send the information to the machine, it's receiving the movements it's supposed to do under the form of a list of points (x,y and z) it's supposed to connect. We have worked with different colors by assigning a depth to each color. The machine works fine and does exactly what it's supposed to do.

 

 

 

 

Don't worry about the questions!

English is not my native tongue and the project itself is difficult to explain! I hope I have been clear now! Don't hesitate to ask me other questions if not! 🙂

 

 

 

One more thing that could be useful to know: right now, when we sketch something, the lines are stocked in an array (each element is a line). Each line is stocked as a cluster of 2 elements: an array for the position (x,y) and a number for the depth the machine is supposed to use for each point in the line.

 

0 Kudos
Message 16 of 25
(1,002 Views)

Hello VGans,

 

Again questions:

- Is the only strict requirement for your carver machine that you should define movements via point (x,y,z) to other points (x,y,z) ?

- Is it absolutely necessary to first carve the exterior circle (or other figure) before carving the inner points/lines?

  If yes, please explain why this is necessary for such a carver?

 

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 17 of 25
(988 Views)

Hi Thierry,

 

 

- Is the only strict requirement for your carver machine that you should define movements via point (x,y,z) to other points (x,y,z) ?

       Yes. (So between 2 points, it's always a straight line, but it quite precise. We've managed to make it draw everything we want)

 

- Is it absolutely necessary to first carve the exterior circle (or other figure) before carving the inner points/lines?

       No, the lines can take a every form possible. The only requirement is that it has a start point and and end point (even if those are the same). So it can go from anywhere.

 

 

Thanks again for your help!! 🙂

0 Kudos
Message 18 of 25
(982 Views)

Hello VGans,

 

A question on the side:

- Is this related to a school/university project?

  If yes, do you have any background in image processing?

 

On-topic question:

- If you have a horizontal line move of multiple pixels (that is one pixel wide) on your bitmap. (eg. only x changes and Y and z remain the same).

  How does this one-pixel width of the line on the bitmap relate to the size of your physical "drill/carving pin"? (don't know if this is an appropriate term.

 

  Example: if you have two lines on a bitmap that are parallel to eachother with a white line in between that has a 1 pixel width.

  Do you then physically see this "white line" on the bitmap sticking out on the object you're carving in?

  If yes:
  If you now draw a line over the "white line", does this then remove the previously sticking out part fully?


  Or in other words:
  How does one pixel of the bitmap relate/map to the "resolution" of the carver?

 
  Or in yet again another way seen:

  Is your carver resolution finer than your bitmap resolution?

  Or is it the other way around? 

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 19 of 25
(975 Views)

A question on the side:

- Is this related to a school/university project? It's a project for an internship in an university research department.

  If yes, do you have any background in image processing? Some but not much.

 

On-topic question:

Is your carver resolution finer than your bitmap resolution?

I guess it will depend on the resolution of the picture. The carver has a resolution of 0.00625mm (0.00024”), which means that the smallest move it can make is 0.00625mm, but the carved lines themselves depend on the drill (which is quite fine).

 

Is that what you wanted to know?

0 Kudos
Message 20 of 25
(964 Views)