Prev: Logistic regression
Next: symbolic transfer function
From: Paul on 4 Aug 2010 05:34 Hi everyone, I'm adding edge detection to a greyscale image. I want to alter the thresh to remove unwanted artifacts/false positives. How do I add thresh this part of my code (below)? e = edge (grey, 'sobel'); I want to be able to alter the value for thresh to tweak the edge detection to give me optimal results before further processing. I just don't understand where to slot "thresh" in, and how to manipulate the value, rather than accepting matlabs automatic value. Thanks in advance, Paul
From: David Young on 4 Aug 2010 06:03 From the help information for edge: "BW = edge(I,'sobel',THRESH) specifies the sensitivity threshold for the Sobel method. edge ignores all edges that are not stronger than THRESH. If you do not specify THRESH, or if THRESH is empty ([]), edge chooses the value automatically." Seems clear, so I'm not sure what your problem is. By the way, it may be worth trying 'canny' as well as 'sobel' - because canny incorporates some smoothing, it tends to give cleaner results. You can experiment with the smoothing constant to tweak it.
From: Paul on 4 Aug 2010 06:32 "David Young" <d.s.young.notthisbit(a)sussex.ac.uk> wrote in message <i3bdso$l3p$1(a)fred.mathworks.com>... > From the help information for edge: > > "BW = edge(I,'sobel',THRESH) specifies the sensitivity threshold for > the Sobel method. edge ignores all edges that are not stronger than > THRESH. If you do not specify THRESH, or if THRESH is empty ([]), > edge chooses the value automatically." > > Seems clear, so I'm not sure what your problem is. > > By the way, it may be worth trying 'canny' as well as 'sobel' - because canny incorporates some smoothing, it tends to give cleaner results. You can experiment with the smoothing constant to tweak it. Hi David, I'm new to matlab, so it's not so obvious to me. If I wanted to specify a value for thresh, do I just replace literally "THRESH" with a value? Paul
From: Paul on 4 Aug 2010 07:00 Also, I have already tried to use canny and it results in too many artifacts. I'm attempting to detect shiny circular objects on a shiny surface. In reality they are rivet heads set into aluminium car bodies.
From: David Young on 4 Aug 2010 07:11
Yes, you can just put a numerical value where the word THRESH appears in the function description. I'm not sure what value is likely to work well - you'll need to experiment. It's better practice to use a variable, rather than putting the number directly into the call to the function. Something like this: thresh = 0.5; bw = edge(grey, 'sobel', thresh); One advantage of this is that the name "thresh" for the variable will remind you later what it does. Another is that it makes it easier to systematically change the value, say in a loop. If you're going to use Matlab much, it would be well worth spending some time looking at the introductory tutorials accessible from the help window or a book on Matlab to learn about the core language. Then if you're doing much image processing, "Digital Image Processing using Matlab" by Gonzalez, Woods and Eddins is worth having handy. |