how to calculate signal to noise ratio for a particular section in an image automatically

hi how to calculate signal to noise ratio for a particular section in an image automatically

9 Comments

Do you have the noise? And the ground truth signal? And what does "automatically" mean, say, as opposed to manually?
I have an image of tank. I have to calculate the non target section of that tank. That means I have to calculate the signal energy at particular portion. The image is at certain angle, which is taken from a space craft radar. It has noise too
You need to know the noise if you are to get the signal to noise ratio. Can you estimate the noise from some area that is supposed to be uniform and noise free?
Then just do
snr = yourImage / theEstimatedNoiseValue;
theEstimatedNoiseValueis the value that you say you can estimate from analyzing some area that is known to be uniform and should be noise free but is not.
Which part of that image are you estimating the noise from?
non target section that is the section around the tank
I don't see a tank. A water tank? A military tank? Anyway, did you try the formula I gave you already a few comments ago? When I asked you "Can you estimate the noise from some area that is supposed to be uniform" and you replied "Yes", what value did you get? Or did you mean that Image Analyst can do it, but seshi can't?
hey its a military tank having the white spots and the black part in the image is field, actually i did not get you at that time i calculated peak signal to noise ratio
clear;
clc;
load hb04039;
load hb06158;
oi=hb04039;
A = imnoise(oi,'salt & pepper', 0.02);
%Calculate the PSNR.
[peaksnr, snr] = psnr(A, oi);
fprintf('\n The Peak-SNR value is %0.4f', peaksnr);
fprintf('\n The SNR value is %0.4f \n', snr);
by using the above code
The Peak-SNR value is 20.4011
The SNR value is -0.1369
i got the above values but what i want is the signal to noise ratio of the black part in that image

Sign in to comment.

 Accepted Answer

You can get a mask of the tank by thresholding at some value, like 40 or 100 or whatever works well
mask = oi < 40;
% Get the pixels in the mask in the oi image
signalPixels = oi(mask);
% Get the pixels in the mask in the noisy image.
noisePixels = A(mask);
% Get the mean SNR over all those pixels
% First get the SNR on a pixel by pixel basis, then take the mean.
snr = mean(signalPixels ./ noisePixels);
Of course you need to handle zero signal and zero noise cases.

5 Comments

Yeah, like I said. That's probably a 0/0 case. Decide what you want to do in cases like that and handle it. If you want you can use nanmeans that I think is in the Stats toolbox.
cant i change that string to numerical value is there any command for that
You can get rid of the nans. See the code below:
A = [1 2 5 6 7 8 nan 20 21 22 23 nan -2 -1 0 nan 1 2]
nanIndexes = isnan(A)
A(nanIndexes) = [] % Remove nans.

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!