示例#1
0
        public TypicalImage custom_filter(float[,] filter, int width, int height, Postprocessing post)
        {
            FWidth  = width;
            FHeight = height;

            return(LinearFilter(filter, FWidth / 2, FHeight / 2, post));
        }
示例#2
0
        public TypicalImage LinearFilter(float[,] filter, int Origx, int Origy, Postprocessing post)
        {
            TypicalImage img = new TypicalImage(this);
            TypicalImage edited_img = new TypicalImage(this);
            int          padWidth, padHeight;

            double[] buffer = new double[width * height * 3];
            int      z = 0;

            padWidth  = Math.Max(FWidth - Origx, Origx);
            padHeight = Math.Max(FHeight - Origy, Origy);
            img.padding(padWidth, padHeight);

            for (int y = padHeight; y < height + padHeight; y++)
            {
                for (int x = padWidth; x < width + padWidth; x++, z += 3)
                {
                    float R = 0, G = 0, B = 0;

                    for (int i = 0; i < FWidth; i++)
                    {
                        for (int j = 0; j < FHeight; j++)
                        {
                            R += img.buffer2d[x - Origx + i, y - Origy + j].R * filter[i, j];
                            G += img.buffer2d[x - Origx + i, y - Origy + j].G * filter[i, j];
                            B += img.buffer2d[x - Origx + i, y - Origy + j].B * filter[i, j];
                        }
                    }
                    buffer[z]     = R;
                    buffer[z + 1] = G;
                    buffer[z + 2] = B;
                }
            }

            if (post == Postprocessing.Cut_off)
            {
                edited_img.cut_off(buffer);
            }
            else if (post == Postprocessing.No)
            {
                edited_img.no_postprocess(buffer);
            }
            else if (post == Postprocessing.Absolute)
            {
                edited_img.absolute(buffer);
            }
            else if (post == Postprocessing.Normalization)
            {
                edited_img.normalization(buffer, edited_img);
            }
            return(edited_img);
        }
示例#3
0
        public TypicalImage LinearFilter(float[,] filter,int Origx, int Origy, Postprocessing post)
        {
            TypicalImage img = new TypicalImage(this);
            TypicalImage edited_img = new TypicalImage(this);
            int padWidth, padHeight;

            double[] buffer = new double[width * height * 3];
            int z = 0 ;
            padWidth = Math.Max(FWidth - Origx, Origx);
            padHeight = Math.Max(FHeight - Origy, Origy);
            img.padding(padWidth, padHeight);

            for (int y = padHeight; y < height + padHeight; y++)
            {
                for (int x = padWidth; x < width + padWidth; x++,z += 3)
                {

                    float R = 0, G = 0, B = 0;

                    for (int i = 0; i < FWidth; i++)
                    {
                        for (int j = 0; j < FHeight; j++)
                        {
                            R += img.buffer2d[x - Origx + i, y - Origy + j].R * filter[i, j];
                            G += img.buffer2d[x - Origx + i, y - Origy + j].G * filter[i, j];
                            B += img.buffer2d[x - Origx + i, y - Origy + j].B * filter[i, j];
                        }
                    }
                    buffer[z] = R;
                    buffer[z + 1] = G;
                    buffer[z + 2] = B;
                }
            }

            if (post == Postprocessing.Cut_off)
            {
               edited_img.cut_off(buffer);
            }
            else if (post == Postprocessing.No)
            {
                edited_img.no_postprocess(buffer);
            }
            else if (post == Postprocessing.Absolute)
            {
                edited_img.absolute(buffer);
            }
            else if (post == Postprocessing.Normalization)
            {
               edited_img.normalization(buffer, edited_img);
            }
            return edited_img;
        }
示例#4
0
        public TypicalImage custom_filter(float[,] filter,int width,int height, Postprocessing post)
        {
            FWidth = width;
            FHeight = height;

            return LinearFilter(filter, FWidth / 2, FHeight / 2, post);
        }