How to calculate signal to noise ratio of hyperspectral image refolded in 2D matrix format?
12 views (last 30 days)
Raw Data (noise affected): 20000x224 (pixel values x wavelengths) (this data has been refolded from 3D array of HSI cube)
Preprocessed data (without noise): 20000x224 (pixel values x wavelengths)
- A single value for SNR
- A plot of SNR
How do I use mean(x) and std(x) to calculate SNR? (or is it even recommended). I am also confused with the language used here, "mean of the image pixel value". Does this mean that I should find a single mean value or mean along the row so that I end up with meanvalues with output of size (20000x1). Similarly, "std at the wavelength". Does this mean that I should calculate stdvalues with output of size (1x224)?
I might have gravely misinterpreted what the author says about SNR and I am figuring out how to implement it with my 2D data.
Subhadeep Koley on 9 Mar 2022
As per my understanding, "A single value for SNR" indicates the overall SNR between the noisy and cleaned data. While in order to obatain a "A plot of SNR", you need to calculate one SNR value per channel (wavelength or band) of the noisy and cleaned data.
The code below is an example of how to do this using the psnr(_) function.
% Load an example 3D image and add noise (Replace this with your HS image)
img = mristack;
noisyImg = imnoise(img,"gaussian",0.0001);
[rw,cl,nChannel] = size(img);
% Refold the images in a 2D matrix format
imgReshaped = reshape(img,[rw*cl,nChannel]);
noisyImgReshaped = reshape(noisyImg,[rw*cl,nChannel]);
% Calculate overall SNR for the entire image
[~,snrVal] = psnr(noisyImgReshaped, imgReshaped);
% Calculate per channel SNR
snrPerChannel = zeros(1,nChannel);
for idx = 1:nChannel
% Plot the per channel SNR