From f618466c25d43f3bae9e40920273bf77de1e1149 Mon Sep 17 00:00:00 2001 From: leochanj105 Date: Mon, 19 Oct 2020 23:09:30 -0400 Subject: initial sd-vbs initial sd-vbs add sd-vbs sd-vbs --- SD-VBS/benchmarks/texture_synthesis/src/matlab/var2.m | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 SD-VBS/benchmarks/texture_synthesis/src/matlab/var2.m (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/var2.m') diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/var2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/var2.m new file mode 100755 index 0000000..6957eff --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/matlab/var2.m @@ -0,0 +1,17 @@ +% V = VAR2(MTX,MEAN) +% +% Sample variance of a matrix. +% Passing MEAN (optional) makes the calculation faster. + +function res = var2(mtx, mn) + +if (exist('mn') ~= 1) + mn = mean2(mtx); +end + +if (isreal(mtx)) + res = sum(sum(abs(mtx-mn).^2)) / max((prod(size(mtx)) - 1),1); +else + res = sum(sum(real(mtx-mn).^2)) + i*sum(sum(imag(mtx-mn).^2)); + res = res / max((prod(size(mtx)) - 1),1); +end -- cgit v1.2.2