03-31-2023 03:05 AM
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.
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!
Solved! Go to Solution.
04-01-2023 06:32 PM - edited 04-01-2023 06:51 PM
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:
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.
04-03-2023 02:49 AM
Exactly what I've needed! Thanks!