LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

draw line around object

Solved!
Go to solution

Capture.PNG

 I have an image created using a 2D array of 0s and 255s to create the image. I am looking to find away to create the red line so that it is always so many indexes away from the object in any direction as shown. Basically I need to run an object around this vehicle while maintaining a specific distance away from it in any direction. 1 index in any direction is about 1". so to be 10" away from the object, I need to be 10 indexes away. Any Suggestion? 

0 Kudos
Message 1 of 8
(134 Views)

Hi John,

 


@john_joe wrote:

I am looking to find away to create the red line so that it is always so many indexes away from the object in any direction as shown. 


Learn from image manipulation applications (like Photoshop or GIMP)!

There are tools like "grow" or "shrink", which do what you want to implement.

Both tools determine an outer border of an image part and grow/shrink the part…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(101 Views)

 

 

I agree with Gerd, there are lots of image processing apps out there which might be easier to use.

 

 

Spoiler

transform the graysacle {0;255} image to a binary image {0;1},

you can caclulate the outline of the binary shape via a custom morphological filters

e.g. the structuring element of an inside-shape pixel will always have sum = 8 with 8-neighborhood, an outline pixel will have a sum between 1 and 7

 

once you caulated all outline pixels, you will have the  original outline-coordinates

add a global offset with respect to the center of mass of the binary shape to this original outline to get an offset-ed outline.

 

0 Kudos
Message 3 of 8
(83 Views)

@john_joe wrote:

 

I have an image created using a 2D array of 0s and 255s to create the image. I am looking to find away to create the red line so that it is always so many indexes away from the object in any direction as shown. Basically I need to run an object around this vehicle while maintaining a specific distance away from it in any direction. 1 index in any direction is about 1". so to be 10" away from the object, I need to be 10 indexes away. Any Suggestion? 


This should be trivially simple to implement in pain LabVIEW. What have you tried?. Simplest would be to just iterate over all points of the image and see how close the nearest black is.

 

altenbach_0-1769702830122.png

 

 

If you want the red line in "any direction" (sic), why isn't there a red outline at the bottom? What should happen if a window is much larger than 10 pixels?

0 Kudos
Message 4 of 8
(60 Views)

Assuming, you want a 10 pixel distance, here's one possible outcome.

(Of course any angled distance will have distances that are not quantized to pixels)

 

altenbach_0-1769707775371.png

 

0 Kudos
Message 5 of 8
(46 Views)

Thanks for the help! After messing around with Grok installed the vison module and used the IMAQ routines to give me what I needed!

 

john_joe_0-1769716577302.png

 

0 Kudos
Message 6 of 8
(32 Views)
Solution
Accepted by topic author john_joe

As an simple exercise, here's a convolution based solution that does not need any toolkit.

Pixel[0,0] is considered the background color, any other color is considered object.

It would be easy to modify, e.g. if you don't want the line below the car.

 

 

altenbach_0-1769720108444.png

 

Message 7 of 8
(18 Views)

Wow that's amazing! That works well too! Thanks I might use your way!

0 Kudos
Message 8 of 8
(9 Views)