How to calculate signal to noise ratio of hyperspectral image refolded in 2D matrix format?
11 ビュー (過去 30 日間)
古いコメントを表示
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:
- A single value for SNR
- A plot of SNR
About SNR:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/912090/image.png)
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.
0 件のコメント
採用された回答
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.
% Load an example 3D image and add noise (Replace this with your HS image)
load("mristack.mat");
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")
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!