示例#1
0
 public ImagesCorrelationStats(ITextureCache cache)
 {
     this.Cache  = cache;
     Image1      = new ImageVarianceStats(cache);
     Image2      = new ImageVarianceStats(cache);
     Correlation = cache.GetTexture();
 }
示例#2
0
        private void RenderImageVariance(ITexture src, ImageVarianceStats dst, LayerMipmapSlice lm)
        {
            // luma values
            lumaTransformShader.Run(src, dst.Luma, lm, models.SharedModel.Upload);
            // expected value
            gaussShader.Run(dst.Luma, dst.Expected, lm, models.SharedModel.Upload, dst.Cache);

            // calculate luma squared
            var lumaSq = dst.Cache.GetTexture();

            multiplyShader.Run(new [] { dst.Luma, dst.Luma }, lumaSq, lm, models.SharedModel.Upload);
            // blur luma squared
            var lumaBlur = dst.Cache.GetTexture();

            gaussShader.Run(lumaSq, lumaBlur, lm, models.SharedModel.Upload, dst.Cache);

            // calc variance with: blurred(luma^2) - mu^2
            subtractProductShader.Run(new [] { lumaBlur, dst.Expected, dst.Expected }, dst.Variance, lm, models.SharedModel.Upload);

            dst.Cache.StoreTexture(lumaSq);
            dst.Cache.StoreTexture(lumaBlur);
        }