# How to calculate signal to noise ratio of hyperspectral image refolded in 2D matrix format?

17 ビュー (過去 30 日間)
Billy Ram 2022 年 3 月 2 日
コメント済み: Billy Ram 2022 年 3 月 13 日
Input:
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)
Preferred output:
1. A single value for SNR
2. A plot of SNR
Doubt:
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 2022 年 3 月 9 日
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.
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
[~,snrPerChannel(1,idx)]=psnr(noisyImgReshaped(:,idx),imgReshaped(:,idx));
end
% Plot the per channel SNR
figure
plot(snrPerChannel,"LineWidth",2)
xlabel("Channels/Bands/Wavelengths")
ylabel("SNR")
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
Billy Ram 2022 年 3 月 13 日
Thank you!

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangeDisplay Point Clouds についてさらに検索

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by