01-03-2017 05:37 PM - edited 01-03-2017 05:37 PM
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
Anyone have any suggestions on the best way to implement this? Thanks!
Solved! Go to Solution.
01-04-2017 03:46 AM
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.
Finally, what is your end goal, to measure the length of the edge? To analyze how the shape changes? Can you expand on this?
01-04-2017 04:26 AM
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.
01-04-2017 09:12 AM
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.
01-06-2017 02:09 PM
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!
01-09-2017 04:46 PM - edited 01-09-2017 05:12 PM
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.
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!
01-10-2017 09:03 AM
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).