Ejemplo n.º 1
0
        /// <summary>
        /// Маркирование
        /// </summary>
        /// <param name="bm">Изображение</param>
        /// <returns>Регионы</returns>
        public Bitmap Marking(Bitmap bm)
        {
            Matrix matr   = ImgConverter.BmpToMatr(bm);
            Matrix filter = new Matrix() - 1;

            filter[1, 1] = 8;
            matr         = NeuroFunc.Threshold(matr, 0.5);
            matr         = 1 - ImgFilters.SpaceFilter(matr, filter);
            matr         = NeuroFunc.Threshold(matr, 0.9);

            BinaryImg bi  = new BinaryImg(1 - matr);
            Matrix    img = bi.ToMatrixInvers();

            //img.MatrixShow();
            x      = 0;
            y      = 0;
            m      = img.M;
            n      = img.N;
            couter = 0;

            while (x < m - 1 && y < n - 1)
            {
                SerchNotMark(img);

                while (Area(img))
                {
                }
            }

            img /= couter;

            return(ImgConverter.MatrixToBitmap(img));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Ретинекс
        /// </summary>
        /// <param name="bm">Картинка</param>
        /// <returns></returns>
        public static Bitmap Retin(Bitmap bm)
        {
            Matrix m       = ImgConverter.BmpToMatr(bm);
            Matrix filter  = new Matrix(5, 5) + 10;
            Matrix filter2 = new Matrix(5, 5);

            filter2[2, 2] = 1;
            double sum = 0;


            for (int i = 1; i < 4; i++)
            {
                for (int j = 1; j < 4; j++)
                {
                    filter[i, j] = 12;
                }
            }



            filter[2, 2] = 18;

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    sum += filter[i, j];
                }
            }

            filter /= 1.7 * sum;
            Matrix bb = ImgFilters.SpaceFilter(m, filter);
            Matrix G  = MathFunc.lg(bb + 0.001);

            m = ImgFilters.SpaceFilter(m, filter2);
            double mean, sigm;

            m    = MathFunc.lg(m + 0.001);
            m   -= G;
            m   -= Statistic.MinimalValue(m.Spagetiz());
            m   /= Statistic.MaximalValue(m.Spagetiz());
            mean = Statistic.ExpectedValue(m.Spagetiz());
            sigm = 0.9 / Statistic.Std(m.Spagetiz());
            m    = NeuroFunc.Sigmoid(sigm * (m - mean));
            return(ImgConverter.MatrixToBitmap(m));
        }