예제 #1
0
        private void testButton__Click(object sender, EventArgs e)
        {
            using (var openFileDialog = new OpenFileDialog())
            {
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    using (var bitmap = new Bitmap(openFileDialog.FileName))
                    {
                        using (var gs = GrayScaleImageHelper.ToGrayScale(bitmap))
                        {
                            using (var gsClone = (Bitmap)gs.Clone())
                            {
                                double[,] result;
                                GrayScaleImageHelper.GetMultiplier1(gs, gsClone, out result);
                                var maxValue = double.MinValue;
                                for (int wi = 0; wi < result.GetLength(0); wi++)
                                {
                                    for (int hi = 0; hi < result.GetLength(1); hi++)
                                    {
                                        if (maxValue < result[wi, hi])
                                        {
                                            maxValue = result[wi, hi];
                                        }
                                    }
                                }

                                MessageBox.Show("" + Math.Round(maxValue));
                            }
                        }
                    }
                }
            }
        }
예제 #2
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);
        }