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

조회 수: 19 (최근 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:
  1. A single value for SNR
  2. A plot of SNR
About 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
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.
% 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개)

카테고리

Help CenterFile Exchange에서 Display Point Clouds에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by