Hi,
I am trying to find how the sobel threshold is defined:
I found :
determine the threshold; see page 514 of "Digital Imaging Processing" by
% William K. Pratt
if isempty(thresh), % Determine cutoff based on RMS estimate of noise
% Mean of the magnitude squared image is a
% value that's roughly proportional to SNR
cutoff = scale*mean2(b);
thresh = sqrt(cutoff);
scale = 4; % for calculating the automatic threshold
So I looked in the book to find an explanation why the scale is 4? but it is not explained, the book states that the threshold can be scaled linearly with the SNR but it does not explain why scale =4. Can someone explain this? I so that there were other post around this topic but I did not find a solution to this question.
txn, regards, J

 Accepted Answer

Image Analyst
Image Analyst on 29 Nov 2013

0 votes

You can use imgradient() to get the full, original Sobel-filtered image. Then you can set a threshold equal to 4 or 5 or whatever you want. It doesn't matter what they did. It only matters what you need to do to get the best results for your particular images.

12 Comments

Yes that I know, I agree I am using the imgradient but I need to support the threshold values scientifically, I can not just argue that I did trial and error. Moreover, I need to apply that filter for a lot of different images and it seems that the automatic threshold of the matlab approach works well, so basically I get that it is proportional to SNR, which explains the scale more or less, but it is not clear why "they" take the squared root
Looks like some kind of "fudge factor" they put in there so that it "worked well" for their images. Working well is subjective so if you pick a threshold by any method, and it works well with your images, then it's scientific enough, at least for me.
Ok, well my idea was to choose the threshold relatively to the SNR, so the threshold can vary among the different images, regards,J
But you don't know the SNR. And I disagree with the comment "Mean of the magnitude squared image is a value that's roughly proportional to SNR" in general, though it might be true for some types of noise and some particular images.
My idea would be to use the mean/st dev as a measurement for SNR, but of course a method open for discussion,
That might be reasonable for images where the noise-free image is uniform. Do you have uniform images, or images that are supposed to be uniform except for the noise? Or do you have some structures in the image that are not supposed to be noise, like subjects in the photos (cars, people, cells, etc.)? You should not call standard deviation due to something that is supposed to be there as noise.
yes, I now the issue on calculating SNR, I need to think of a good way to separate the signal and the noise
Do your images vary, and the noise stay constant? Or is your image the same and the noise varies? Or do they both vary? If you want advice, you can attach 2 or 3 of your images for me to look at.
Well actually we have I phD student that is working on it, but all advise and experience are welcome, so I added two example files.
We want to know the gradient at all edge point of each droplet
I don't see why edge detection is necessary. Just do background correction and thresholding. Or try a tophat or bottomhat filter.
Well the problem is a bit more complex: Our final goal is to determine in a 3D spray which droplet are in focus and which not. Therefore we want to know the gradient of droplets of which we know beforehand that they are in focus. Then that gradient could be used to classify the droplets in the spray.
OK, in that case you probably do want an edge detector. But you don't want to threshold it - you want to take the mean of it. First of all you need to have a window large enough to contain your blur or else you can't tell how much it's blurred. With a 3x3 Sobel filter you can tell when it's in focus but if it's blurred a lot or a huge lot, you'll never be able to tell. So you'll probably want to use a Laplacian of Gaussian or Difference of Gaussian filter. But be aware that if the window is too large, then you'll start picking up on your shading/vignetting, and to prevent that you'll need to do a background correction (which you can do with polyfitn. So then when you have the edges you'd simply want to sum your image (or mean - basically the same thing) to get a metric that indicates how much your image is blurred. If the sum or mean is higher, there are more edges there, indicating sharper edges. I don't really see any benefit to thresholding it for the purpose of either binarizing it or masking it.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!