当前位置: 首页>>代码示例>>C#>>正文


C# IImage.GetPixel方法代码示例

本文整理汇总了C#中IImage.GetPixel方法的典型用法代码示例。如果您正苦于以下问题:C# IImage.GetPixel方法的具体用法?C# IImage.GetPixel怎么用?C# IImage.GetPixel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IImage的用法示例。


在下文中一共展示了IImage.GetPixel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: median_filter

        //Bitmap my_bitmap
        //МЕДИАННЫЙ ФИЛЬТР!!!!!!!!!!
        private void median_filter(IImage image, int x, int y)
        {
            int n;//элемнты в массиве
            int cR_, cB_, cG_;//искомые медианные значения
            int k = 1;

            n = (2 * rad + 1) * (2 * rad + 1); //?

            //    toolStripProgressBar2.Step = 1;
            //  toolStripProgressBar2.Maximum = n;

            // обнуляем массив ---------------------------
            int[] cR = new int[n + 1];
            int[] cB = new int[n + 1];
            int[] cG = new int[n + 1];

            for (int i = 0; i < n + 1; i++)
            {
                cR[i] = 0;
                cG[i] = 0;
                cB[i] = 0;
            }
            //--------------------------------------------
            int w_b = image.Width;
            int h_b = image.Height;

            for (int i = x - rad; i < x + rad + 1; i++)
            {
                for (int j = y - rad; j < y + rad + 1; j++)
                {

                    Pixel pixel = image.GetPixel(i, j);
                    cR[k] = Convert.ToInt32(pixel.R);
                    cG[k] = Convert.ToInt32(pixel.G);
                    cB[k] = Convert.ToInt32(pixel.B);
                    k++;

                }
            }

            quicksort(cR, 0, n - 1);//сортируем массивы
            quicksort(cG, 0, n - 1);
            quicksort(cB, 0, n - 1);

            int n_ = (int)(n / 2) + 1;

            cR_ = cR[n_];
            cG_ = cG[n_];
            cB_ = cB[n_];

            image.SetPixel(x, y, new Pixel { R = (byte)cR_, G = (byte)cG_, B = (byte)cB_ });
        }
开发者ID:VysotskiVadim,项目名称:bsuir-misoi-car-number,代码行数:54,代码来源:MedianFilter.cs

示例2: ProcessImage

 public void ProcessImage(IImage image)
 {
     byte threshold = OtsuTreshold(image);
     for (int i = 0; i < image.Width; i++)
     {
         for (int j = 0; j < image.Height; j++)
         {
             byte red = image.GetPixel(i, j).R;
             byte newPixel = red > threshold ? (byte)255 : (byte)0;
             image.SetPixel(i, j, new Pixel { B = newPixel, G = newPixel, R = newPixel });
         }
     }
 }
开发者ID:VysotskiVadim,项目名称:bsuir-misoi-car-number,代码行数:13,代码来源:OtsuBinarization.cs

示例3: Filter

        public void Filter(IImage image, double[,] filter)
        {
            if (filter.GetLength(0) != filter.GetLength(1))
            {
                throw new ArgumentException("invalid filter", nameof(filter));
            }

            var result = new Pixel[image.Width, image.Height];

            double blue = 0.0;
            double green = 0.0;
            double red = 0.0;

            int filterOffset = (filter.GetLength(0) - 1) / 2;
            for (int offsetY = filterOffset; offsetY < image.Height - filterOffset; offsetY++)
            {
                for (int offsetX = filterOffset; offsetX < image.Width - filterOffset; offsetX++)
                {
                    blue = 0;
                    green = 0;
                    red = 0;

                    for (int filterY = -filterOffset; filterY <= filterOffset; filterY++)
                    {
                        for (int filterX = -filterOffset; filterX <= filterOffset; filterX++)
                        {
                            var imagePixel = image.GetPixel(offsetX + filterX, offsetY + filterY);

                            blue += (double)(imagePixel.B) * filter[filterY + filterOffset, filterX + filterOffset];
                            green += (double)(imagePixel.G) * filter[filterY + filterOffset, filterX + filterOffset];
                            red += (double)(imagePixel.R) * filter[filterY + filterOffset, filterX + filterOffset];
                        }
                    }

                    blue = Factor * blue + Bias;
                    green = Factor * green + Bias;
                    red = Factor * red + Bias;

                    result[offsetX, offsetY] = new Pixel { R = this.ToByte(red), G = this.ToByte(green), B = this.ToByte(blue) };
                }
            }

            for (int x = 0; x < result.GetLength(0); x++)
            {
                for (int y = 0; y < result.GetLength(1); y++)
                {
                    image.SetPixel(x, y, result[x, y]);
                }
            }
        }
开发者ID:VysotskiVadim,项目名称:bsuir-misoi-car-number,代码行数:50,代码来源:ConvolutionFilter.cs

示例4: ProcessImage

        public void ProcessImage(IImage image)
        {
            Pixel c;

            byte[] gammaArray = CreateGammaArray(GammaValue);

            for (int i = 0; i < image.Width; i++)
            {
                for (int j = 0; j < image.Height; j++)
                {
                    c = image.GetPixel(i, j);
                    image.SetPixel(i, j, new Pixel { R = gammaArray[c.R], G = gammaArray[c.G], B = gammaArray[c.B] });
                }
            }
        }
开发者ID:DashaVeresova,项目名称:RecognitionOfDrivingLicenses,代码行数:15,代码来源:GammaFilter.cs

示例5: CalculateLineHistogram

        public int[] CalculateLineHistogram(IImage image)
        {
            int[] histogram = new int[image.Width];;
            ConverToGrayColors(image);
            _binarizationFilter.ProcessImage(image);

            for (var i = 0; i < image.Width; i++)
            {
                for (var j = 0; j < image.Height; j++)
                {
                    if (image.GetPixel(i, j).R == 255)
                    {
                        histogram[i]++;
                    }
                }
            }
            return histogram;
        }
开发者ID:VysotskiVadim,项目名称:bsuir-misoi-car-number,代码行数:18,代码来源:TextFindProcessor.cs

示例6: ImageHistogram

        private int[] ImageHistogram(IImage input)
        {
            int[] histogram = new int[256];

            for (int i = 0; i < histogram.Length; i++)
            {
                histogram[i] = 0;
            }

            for (int i = 0; i < input.Width; i++)
            {
                for (int j = 0; j < input.Height; j++)
                {
                    int red = input.GetPixel(i, j).R;
                    histogram[red]++;
                }
            }
            return histogram;
        }
开发者ID:VysotskiVadim,项目名称:bsuir-misoi-car-number,代码行数:19,代码来源:OtsuBinarization.cs

示例7: GetIndencity

 private byte GetIndencity(IImage image, int x, int y)
 {
     var pixel = image.GetPixel(x, y);
     return (byte)((pixel.R + pixel.G + pixel.B) / 3);
 }
开发者ID:DashaVeresova,项目名称:RecognitionOfDrivingLicenses,代码行数:5,代码来源:BinarizationFilter.cs

示例8: GetIntensityFrom

        private byte[,] GetIntensityFrom(IImage image)
        {
            if (image == null) throw new ArgumentNullException(nameof(image));

            var intencity = new byte[image.Width, image.Height];
            for (var i = 0; i <= image.Width - 1; i++)
            {
                for (var j = 0; j <= image.Height - 1; j++)
                {
                    intencity[i, j] = this.Intensity(image.GetPixel(i, j));
                }
            }
            return intencity;
        }
开发者ID:DashaVeresova,项目名称:RecognitionOfDrivingLicenses,代码行数:14,代码来源:TextFindProcessor.cs


注:本文中的IImage.GetPixel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。