Code covered by the BSD License

# Image Quality - Index Analysis GUI

### Aristidis Vaiopoulos (view profile)

29 Apr 2013 (Updated )

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

div_fs(x,y,ws,absval)
```function [div, div_map] = div_fs(x,y,ws,absval)

% DIV calculator
%Difference In Variance

% Formula: 1 - variance(fused image)/variance(original image)
% (Ideal value = 0)

% 07/03/2010 Version 1.0
% 25/06/2010 Version 1.2    -   Excel Output option
% 06/08/2011 Version 1.2F   -   Function version
% 04/08/2012 Version 2.2F   -   Sliding window
% 27/01/2013 Version 3.2F   -   Calculates index from valid area
% 21/02/2013 Version 4.2F   -   Absolute value option

% Author: Aristidis D. Vaiopoulos

if nargin < 2
error('This function needs at least 2 arguments')
end
% Default window size
if nargin == 2
ws = 8;
absval = 1;
end
if nargin == 3
absval = 1;
end

x = single(x);
y = single(y);

% Sum filter
sf = ones(ws);
% Mean filter
mf = sf / (ws^2);
% Local Variances
vx = filter2( sf,(x - filter2(mf,x)) ) / ((ws^2)-1);
vy = filter2( sf,(y - filter2(mf,y)) ) / ((ws^2)-1);
% DIV map
div_map = 1 - vy./vx;
% Kill Nans
div_map = nankill(div_map,0);
% Kill Infs
div_map = infkill(div_map,0);
% Overall DIV
if absval == 1
div_map = abs(div_map);
end
s = round(ws/2);
div = mean2( div_map(s:end-s,s:end-s) );

end
```