/// <summary> /// Calculates the mean squared error of this and another DeblurFactor /// </summary> /// <param name="deblurFilter"></param> /// <returns></returns> public Complex GetMse(DeblurFilter deblurFilter) { double errorRe = 0; double errorIm = 0; //var r1 = Data.Channel1; //var g1 = Data.Channel2; //var b1 = Data.Channel3; //var r2 = blurFactor.Data.Channel1; //var g2 = blurFactor.Data.Channel2; //var b2 = blurFactor.Data.Channel3; //var ilength = r1.Width; //var jlength = r1.Width; Action <Complex, Complex, int, int> action = delegate(Complex c1, Complex c2, int i, int j) { var divRe = c2.Real - c1.Real; var divIm = c2.Imaginary - c1.Imaginary; errorRe += divRe * divRe; errorIm += divIm * divRe; }; C0.FoldWith(deblurFilter.C0, action); C1.FoldWith(deblurFilter.C1, action); C2.FoldWith(deblurFilter.C2, action); //for (var j = 0; j < jlength; j++) // for (var i = 0; i < ilength; i++) // { // var divR = r2[i][j].Real - r1[i][j].Real; // var divG = g2[i][j].Real - g1[i][j].Real; // var divB = b2[i][j].Real - b1[i][j].Real; // var divRi = r2[i][j].Imaginary - r1[i][j].Imaginary; // var divGi = g2[i][j].Imaginary - g1[i][j].Imaginary; // var divBi = b2[i][j].Imaginary - b1[i][j].Imaginary; // errorRe += divR*divR; // errorRe += divG*divG; // errorRe += divB*divB; // errorIm += divRi*divRi; // errorIm += divGi*divGi; // errorIm += divBi*divBi; // } return(new Complex(errorRe, errorIm)); }