LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help connecting edges after running an edge detection method on an image

Solved!
Go to solution

I am hoping to get a little bit of help with a project I am currently working on.  I am trying to detect an object in a scene that has the ability to change over time.  Both the object (the shape and contrast) and the scene itself change.  One of the hurdles I have encountered is the following:

 

After I have ran my edge detection methods and have the resulting image with the detected edges I want to interpolate between (or essentially connect) some of those edges. The ideal solution would result in the following image seen below

 edge detect.png

 

Anyone have any suggestions on the best way to implement this?  Thanks!

0 Kudos
Message 1 of 7
(4,751 Views)

A couple of questions:

- What image processing tool are you using? NI IMAQ Vision?

- You mention that the object (shape and contrast) changes over time, are you expecting to be able to track the edge(s) automatically, or would manual tweaking of the analysis parameters be ok?

 

   One of the problems here is that the definition of edge is subject to interpretation. Especially in the middle-left part of your image, there are many paths that could be defined as your edge, which one is the right one?

 

   I made some quick experiments on your image (that I assume has been compressed in your posting, can you attach the original file(s)?). By smoothing it before running the edge detection I was able to get continuous 'lines' at the cost of a wider shape.

 

Edge Detection.jpg

 

   Finally, what is your end goal, to measure the length of the edge? To analyze how the shape changes? Can you expand on this?

 

0 Kudos
Message 2 of 7
(4,697 Views)

Here is what I achieved when subtracting a constant value of 179 from your image before running the edge detection. A simple way of removing the dark particles.

Edge Detection2.jpg

0 Kudos
Message 3 of 7
(4,695 Views)

 LocalDSP is right, it is better to get the best edges before processing them. To answer original question, try Imaq morphology, Close operation, it will connect edges, separated by 1 pixel. If you increase size of the kernel, it increases distance to connect, but hides small details.

0 Kudos
Message 4 of 7
(4,677 Views)

Thanks for the suggestions guys,  I'll review what you said and see what I can come up with.  Hopefully report back with something monday!

0 Kudos
Message 5 of 7
(4,658 Views)

Sorry for the delayed response, I'll start by answering your original questions...

-I am using NI IMAQ Vision (2016)

-I am hoping for it to be automatic, The edge doesnt need to be perfect but at least close the majoriity of the time.

- The end goal is to measure the size of the white blob in the image (the bed), The idea is when the edge is properly defined I would use a find contour algorithm and get the longest one (possible issues there).  Assuming everything went well, everything below that edge/controur would be filled and considered as part of the bed.  See image below for an example of it working well.

ideal.png

 

Anyways, I tried subtracting a constant 175 and got similiar results to you.  I am curious though, what form of edge detection are you using?  I am using Canny+Differential.  What specific smoothing techniques did you use? Did you use some Gray Morphology close/dilate functions after the edge detection?  I would love to mess around with whatever you used to get the wider edges.

 

Thanks again for your help!

0 Kudos
Message 6 of 7
(4,636 Views)
Solution
Accepted by topic author cathair28

I have attached the (Lv2014) VI that I used for my quick experiments. It is all very empirical and manually tweaked for that particular image, so likely far from ideal processing but I hope you can use it for inspiration. I also tried smoothing based on frequency domain truncation but did not achieve significant improvements.

 

I originally tried to avoid operations like dilatation as it can be difficult to control. While it may join broken edges, it can also create connections that are definitely not intended. It's always better to pre-process the image as much as possible before resorting to morphology tools. Here is the result of the processing using the attached VI default paramters (yellow color fill added manually to check continuity).

 

Edge Detection with Morphology.bmp

0 Kudos
Message 7 of 7
(4,622 Views)