Code covered by the BSD License  

Highlights from
Image Quality - Index Analysis GUI

image thumbnail

Image Quality - Index Analysis GUI

by

 

29 Apr 2013 (Updated )

This GUI measures the image quality/error between 2 or more images (original,test1/test2/.../testn).

ergas3d(x,y,resratio,ws)
function [ergas_pb, ergas_mpb, ergas, ergas_map] = ergas3d(x,y,resratio,ws)

% ERGAS calculator

% 19/08/2009 Version 1.0
% 02/12/2009 Version 1.5    - hyperspectral support
% 05/03/2010 Version 2.0    - Double precision, RAM efficiency
% 07/03/2010 Version 3.0    - Progressbar
% 07/08/2011 Version 3.0F   - Function Version
% 26/01/2013 Version 4.0F   - Sliding window
% 27/01/2013 Version 5.0F   - Calculates index from valid area

% Author: Aristidis D. Vaiopoulos


if nargin < 2
    error('This function needs at least 2 arguments')
end
% Default window size
if nargin == 3
    ws = 8;
end
% Find bands
nb = size(x,3);
% Preallocate
rmse_map = single(zeros(size(x)));
% Calculate RMSE for every band
for b = 1:nb
    rmse_map(:,:,b) = rmse_fs(x(:,:,b),y(:,:,b),ws);
end

x = single(x);
mf = fspecial('average',ws);
meansx = imfilter(x,mf,'replicate');

%ERGAS part
presratio = 100*resratio;
% ERGAS per band
ergasroot = sqrt( (rmse_map.^2)./(meansx.^2) );
ergas_mpb  = presratio*ergasroot;
% Kill Nans
ergas_mpb = nankill(ergas_mpb,0);
% Kill Infs
ergas_mpb = infkill(ergas_mpb,1);
s = round(ws/2);
ergas_pb = mean3( ergas_mpb(s:end-s,s:end-s,:) );
% ERGAS considering all bands (original)
ergasroot = sqrt( sum( ( (rmse_map.^2)./ (meansx.^2) ) ,3) / nb );
ergas_map = presratio*ergasroot;
% Kill Nans
ergas_map = nankill(ergas_map,0);
% Kill Infs
ergas_map = infkill(ergas_map,1);
ergas     = mean2( ergas_map(s:end-s,s:end-s) );


end

Contact us