Exemplo n.º 1
0
        public void ApplyMask(double[][] maskH, double[][] maskV, int treshe = 0)
        {
            Color[][] colorsH = ImageExtension.GetolorMatrix(MaskApplier.ApplyMaskForAllChanales(BitmapImg, maskH, treshe));
            Color[][] colorsV = ImageExtension.GetolorMatrix(MaskApplier.ApplyMaskForAllChanales(BitmapImg, maskV, treshe));
            ResultImg = new Bitmap(BitmapImg);

            if (chanel == ColorChannel.All)
            {
                for (int i = 0; i < colorsH.Length; i++)
                {
                    for (int j = 0; j < colorsH[0].Length; j++)
                    {
                        var r = Math.Sqrt((colorsH[i][j].R * colorsH[i][j].R) + (colorsV[i][j].R * colorsV[i][j].R));
                        var g = Math.Sqrt((colorsH[i][j].G * colorsH[i][j].G) + (colorsV[i][j].G * colorsV[i][j].G));
                        var b = Math.Sqrt((colorsH[i][j].B * colorsH[i][j].B) + (colorsV[i][j].B * colorsV[i][j].B));

                        ResultImg.SetPixel(i, j, Color.FromArgb(255, (byte)r, (byte)g, (byte)b));
                    }
                }
            }
            else
            {
                var initialColors = ImageExtension.GetolorMatrix(BitmapImg);
                for (int i = 0; i < colorsH.Length; i++)
                {
                    for (int j = 0; j < colorsH[0].Length; j++)
                    {
                        var r = (chanel == ColorChannel.Red)
                            ? Math.Sqrt((colorsH[i][j].R * colorsH[i][j].R) + (colorsV[i][j].R * colorsV[i][j].R))
                            : initialColors[i][j].R;
                        var g = (chanel == ColorChannel.Green)
                            ? Math.Sqrt((colorsH[i][j].G * colorsH[i][j].G) + (colorsV[i][j].G * colorsV[i][j].G))
                            : initialColors[i][j].G;
                        var b = (chanel == ColorChannel.Blue)
                            ? Math.Sqrt((colorsH[i][j].B * colorsH[i][j].B) + (colorsV[i][j].B * colorsV[i][j].B))
                            : initialColors[i][j].B;

                        ResultImg.SetPixel(i, j, Color.FromArgb(255, (byte)r, (byte)g, (byte)b));
                    }
                }
            }

            var reHisto = HistogramCalc.GetHistogram(ResultImg, Chanel);

            var values = new ChartValues <ObservableValue>();

            foreach (var item in reHisto)
            {
                values.Add(new ObservableValue(item));
            }

            WorkCollection = new SeriesCollection
            {
                new ColumnSeries
                {
                    Values = values
                }
            };
        }
Exemplo n.º 2
0
        private ChartValues <ObservableValue> GetNewWorkHisto()
        {
            if (ResultImg != null)
            {
                var resWorkHisto = HistogramCalc.GetHistogram(ResultImg, Chanel);

                var workValues = new ChartValues <ObservableValue>();

                foreach (var item in resWorkHisto)
                {
                    workValues.Add(new ObservableValue(item));
                }

                return(workValues);
            }
            return(null);
        }
Exemplo n.º 3
0
        private ChartValues <ObservableValue> GetNewHisto()
        {
            if (BitmapImg != null)
            {
                var reHisto = HistogramCalc.GetHistogram(BitmapImg, Chanel);
                var values  = new ChartValues <ObservableValue>();

                foreach (var item in reHisto)
                {
                    values.Add(new ObservableValue(item));
                }

                return(values);
            }

            return(null);
        }