How to find value PSNR,MSE and SNR of an image?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i have two m file first i save with PSNR.m that contain
function psnr= PSNR(X,Y)
%Calculates the Peak-to-peak Signal to Noise Ratio of two images X and Y
[M,N]=size(X);
m=double(0);
X=cast(X,'double');
Y=cast(Y,'double');
for i=1:M
for j=1:N
m=m+((X(i,j)-Y(i,j))^2);
end
end
m=m/(M*N);
psnr=10*log10(255*255/m);
and at second m file
function checkbox1_Callback(hObject, eventdata, handles)
global noiseImage
fontSize = 13;
%applyNoise(handles);
%function applyNoise(handles)
if isfield(handles,'imgData')
imgData = handles.imgData;
noiseStr = '';
d = get(handles.popupmenu1,'Value')
items = get(handles.checkbox1,'String');
if get(handles.checkbox1,'Value')
noiseStr = 'Salt & pepper';
imgData = imnoise(imgData,'salt & pepper',d);
PSNR_1=psnr(imgData,img)
set(handles.edit6, 'String',num2str(PSNR_1),'FontSize', fontSize);
end
if get(handles.checkbox2,'Value')
if ~isempty(noiseStr)
noiseStr = [noiseStr ', '];
end
noiseStr = [noiseStr 'Gaussian'];
imgData = imnoise(imgData,'gaussian',0.1,0.1);
end
if get(handles.checkbox3,'Value')
if ~isempty(noiseStr)
noiseStr = [noiseStr ', '];
end
noiseStr = [noiseStr 'localvar'];
imgData = imnoise(imgData,'localvar',0.05*rand(size(imgData)));
end
if get(handles.checkbox4,'Value')
if ~isempty(noiseStr)
noiseStr = [noiseStr ', '];
end
noiseStr = [noiseStr 'poisson'];
imgData = imnoise(imgData,'poisson');
end
if get(handles.checkbox5,'Value')
if ~isempty(noiseStr)
noiseStr = [noiseStr ', '];
end
noiseStr = [noiseStr 'speckle'];
imgData = imnoise(imgData,'speckle', 0.3);
end
axes(handles.axes2);
imshow(imgData);
PSNR_1=psnr(imgData,imgData)
mse_1=mse(imgData,imgData)
SNR_1=snr(imgData,imgData)
set(handles.edit6, 'String',num2str(PSNR_1),'FontSize', fontSize);
set(handles.edit7, 'String',num2str(mse_1),'FontSize', fontSize);
set(handles.edit8, 'String',num2str(SNR_1),'FontSize', fontSize);
title(['Noise type: ' noiseStr,]);
noiseImage = imgData;
end
I want to show value PSNR,MSE and SNR when i add noise of checkbox 1 at edittext,but the value doesnt show.Hope someone can help me
0 commentaires
Réponses (1)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!