Edge detection is working too well for me?

12 views (last 30 days)
I have a video of an object undergoing cyclic strain-in short, two walls of the object changing position throughout the video. I've written a script to loop through the frames, measure the distance between the two walls, output some values, and move on. To identify these walls, I've had the most success with Canny edge detection. The issue is that the video has relatively little contrast between the walls and rest of the image.
The Canny detection is almost working too well-it often identifies noise between and outside the walls. I grapple with this using a loop that adjusts the threshold value of the edge detector, but that often begins to eliminate the true edges along with the noise.
Is edge detection the best way to go about this? Can I use edge detection in conjunction with another method? Any suggestions would be appreciated as I'm a little stumped.
I'm attaching an example frame below. The conditions here are basically worst case, but I am not in direct control of the quality of the video captured. I'd prefer the script to be as robust as possible to handle some variability in image quality...thanks!
...and here's an edge detection of that image...see how it captures all the stuff in the middle?
It isn't a particularly great example because there are no edges detected outside of the walls (so essentially I could just take the furthest right and furthest left), but that doesn't consistently happen (and varies within a video).

Accepted Answer

Thorsten
Thorsten on 30 Jun 2016
If the walls are always vertical, you can sum the output of the edge detector across all rows and determine the x positions from the maximum in the left and the right part.
  5 Comments
Thorsten
Thorsten on 1 Jul 2016
Almost all edge detection algorithms compute the difference between adjacent pixels, in one way or another. The simplest method is to run the diff across the image. If that works, why use a more sophisticated method?
The reason that it works so nicely is of course that you pool the results across all rows, and because the image is so simple and is supposed to contain just two edges.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 30 Jun 2016
I'm also going to suggest that you take the color channel that has the most contrast (probably the red) and sum it vertically
horizontalProfile = mean(rgbImage(:, :, 1), 1); % Mean going down rows.
Then examine the profile and look for indicators of where an edge is.
Failing that, you can look at the Canny blobs with regionprops() and throw out any with an aspect ratio that is not really high, like 100 or so. That should get you stick-like objects. You may still have to connect sticks if they're broken. There are a number of ways to look at aspect ratio. You can look at BoundingBox or Eccentricity or MajorAxisLength./MinorAxisLength or area divided by endpoint distances, etc.
You might try doing noise reduction on the image first. Like medfilt2() or even conv2(). Blurring won't change the location of the edge so don't worry about that.
  1 Comment
MJU
MJU on 30 Jun 2016
Was hoping you'd respond on this...I've seen you all across this forum. thanks! :)

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!