From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Vision assistant: detect edges on a binary image

Solved!
Go to solution

Hi,

 

I need to detect the edges of a label. The surroundings of the label is quite noisy so after a "Color threshold (color model RGB)" and a "basic morphology" I have ended up with the image below which looks perfect for finding the edge of the label.

 

1984_0-1680248934882.png

 

In order to able to use the Find straight edge function I converted the image back to 8-bit, I16 or U16 (doesnt seem to matter). Now I can use the function but because I only have 2 colors (0 and 1) and the find straight edge could not find a fractional edge (eg: 0.75) no edges were found. 

 

I thought I could use the color operators function to multily my image by any color (so pixels with the value 1 would change to something bigger and use the straight edge then), but I cant because I dont know how to convert this image back to RGB(32bit) which is a precondition for executing the color operators. (also I'm not sure if that would work, but that was my idea)

 

So my question is: what should I do to be able to detect the horizontal and vertical edges of this image?

 

Thanks!

0 Kudos
Message 1 of 3
(758 Views)
Solution
Accepted by topic author 1984

Hi 1984,

 

Could you post the original image ?

Since you opted for image binarization, I would have gone further and used the convex hull to fill the holes completely.

Also, if the goal is to use the grayscale straight edge detector, keep in mind that with binarization, you are losing the subpixel precision for finding the edges.

 

Here is the result I got just from your image, using binarization and convex hull:

raphschru_0-1680391231427.png

 

Attached is the script I used.

 

Also for your specific question about how to convert the image back to RGB, I'm not sure whether you can do that with Vision Assistant, but you surely could achieve it with a VI, by converting the image to a U8 2D array, then to a U32 2D array, and finally to a new RGB image.
In Vision Assistant, I somehow managed to get back to a "pseudo-grayscale" image by multiplying the binary image by 255, but it is still considered as a binary image. Using the "Conversion" function to convert it to a true 8-bit image does not seem to work (which may be a bug…). Fortunately, the Advanced Straight Edge Detector works on binary images.

Message 2 of 3
(716 Views)

Exactly what I've needed! Thanks!

0 Kudos
Message 3 of 3
(689 Views)