Exemplo n.º 1
0
        // Radometric Simillarity returns doubles 0..1.
        // They are converted to grayscale bitmap for quantification and future analysis.
        private Bitmap GetRadiometricSimmilarity(
            int width,
            int height,
            int stride,
            byte[] grayScaleData,
            out byte[,] dataHeigthWidth,
            out byte[,] imageTMeanWH,
            out byte[,] imageTVarianceWH)
        {
            GrayScaleImageHelper.CalculateMeanAndVarianceM9(
                width,
                height,
                stride,
                grayScaleData,

                out imageTMeanWH,
                out imageTVarianceWH);

            // Radiometric simillarity.
            GCHandle handle;
            var      result = GrayScaleImageHelper.BeginImage(width, height, out dataHeigthWidth, out handle);

            double[,] firstItemWH;
            GrayScaleImageHelper.GetMultiplier1(width, height, stride, grayScaleData, _grayScaleFrameTMinus1, out firstItemWH);
            for (int widthI = 1; widthI < (width - 1); widthI++)
            {
                for (int heightI = 1; heightI < (height - 1); heightI++)
                {
                    dataHeigthWidth[heightI, widthI] = (byte)
                                                       (
                        byte.MaxValue * (firstItemWH[widthI, heightI] -
                                         imageTMeanWH[widthI, heightI] * _imageTMinus1MeanWH[widthI, heightI]
                                         )
                        /
                        Math.Sqrt(imageTVarianceWH[widthI, heightI] * _imageTMinus1VarianceWH[widthI, heightI]));
                }
            }

            GrayScaleImageHelper.EndImage(handle);
            return(result);
        }