Пример #1
0
        public void FiltroMedia(int raio)
        {
            int r = 0, x, y, i, j, canal;
            int width  = MatrizCor.Width;
            int height = MatrizCor.Height;
            var aux    = MatrizCor;

            for (x = raio; x < width - raio; x++)
            {
                for (y = raio; y < height - raio; y++)
                {
                    for (canal = 0; canal < 3; canal++)
                    {
                        for (i = x - raio; i <= x + raio; i++)
                        {
                            for (j = y - raio; j <= y + raio; j++)
                            {
                                r += aux.Matriz[i, j, canal];
                            }
                        }
                        r /= 9;
                        aux.Matriz[x, y, canal] = r;
                        r = 0;
                    }
                }
            }
            MatrizCor = aux;
        }
Пример #2
0
        public void FiltroMediana(int raio)
        {
            int size = ((2 * raio + 1) * (2 * raio + 1));

            int[] r = new int[size];
            int   x, y, i, j, pos = 0, canal;
            int   w   = MatrizCor.Width;
            int   h   = MatrizCor.Height;
            var   aux = this.MatrizCor;

            for (x = raio; x <= w - raio; x++)
            {
                for (y = raio; y <= h - raio; y++)
                {
                    for (canal = 0; canal < 3; canal++)
                    {
                        for (i = x - raio; i <= x + raio; i++)
                        {
                            for (j = y - raio; j <= y + raio; j++)
                            {
                                r[pos++] = MatrizCor.Matriz[i, j, canal];
                            }
                        }
                        Array.Sort(r);
                        aux.Matriz[x, y, canal] = r[size / 2];
                        pos = 0;
                    }
                }
            }
            MatrizCor = aux;
        }
Пример #3
0
        public void CreatePlainImage(int width, int height, int value)
        {
            int x, y, c;

            MatrizCor = new ImagemInt
            {
                Height = height,
                Width  = width,
                Matriz = new int[width, height, 3]
            };
            for (x = 0; x < width; x++)
            {
                for (y = 0; y < height; y++)
                {
                    for (c = 0; c <= 2; c++)
                    {
                        MatrizCor.Matriz[x, y, c] = value;
                    }
                }
            }
        }
Пример #4
0
        public void DilatacaoCinza(ElEst el, int rx, int ry)
        {
            Imagem img = this;

            int[,] ee = GetEE(el, rx, ry);
            int    h     = this.MatrizCor.Height;
            int    w     = this.MatrizCor.Width;
            Imagem saida = new Imagem();

            saida.Clone(this);
            int x, y, c, i, j, max, aux;

            for (c = 0; c < 3; c++)
            {
                for (x = rx; x < (w - rx); x++)
                {
                    for (y = ry; y < (h - ry); y++)
                    {
                        aux = 0;
                        for (i = -rx; i <= rx; i++)
                        {
                            for (j = -ry; j <= ry; j++)
                            {
                                max = img.MatrizCor.Matriz[x + i, y + j, c] + (ee[rx + i, ry + j]);
                                if (max > aux)
                                {
                                    aux = max;
                                }
                            }
                        }
                        saida.MatrizCor.Matriz[x, y, c] = aux;
                    }
                }
            }

            this.MatrizCor = saida.MatrizCor;
        }