示例#1
0
 private void AddKernel(BSplain.SplainInstance Kernel)
 {
     if (!listBox1.Items.Contains(Kernel.Name))
     {
         listBox1.Items.Add(Kernel.Name);
         listBox2.Items.Add(Kernel.Name);
         listBox3.Items.Add(Kernel.Name);
     }
     else
     {
         int i = 1;
         while (listBox1.Items.Contains(Kernel.Name + "(" + i + ")"))
         {
             i++;
         }
         Kernel.Name += "(" + i + ")";
         listBox1.Items.Add(Kernel.Name);
         listBox2.Items.Add(Kernel.Name);
         listBox3.Items.Add(Kernel.Name);
     }
     Kernels.Add(Kernel);
 }
示例#2
0
        private void button8_Click(object sender, EventArgs e)
        {
            BSplain.SplainInstance target = new BSplain.SplainInstance();
            if (WorkingImage.Count < 1)
            {
                LogOutputTextBox.Text += "Спочатку виберіть зображення";
                return;
            }
            int height = WorkingImage[WorkingImage.Count - 1].GetUpperBound(1) + 1;
            int width  = WorkingImage[WorkingImage.Count - 1].GetUpperBound(2) + 1;

            double[,,] result = new double[3, height, width];

            int filterWidth  = target.MatrixForm.GetUpperBound(1) + 1;
            int filterHeight = target.MatrixForm.GetUpperBound(0) + 1;
            int ShortSide1   = (int)((filterHeight - 1d) / 2);
            int ShortSide2   = (int)((filterHeight - 1d) / 2);
            int LongSide1    = (int)Math.Ceiling((filterHeight - 1d) / 2);
            int LongSide2    = (int)Math.Ceiling((filterHeight - 1d) / 2);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    double pixelR = 0;
                    double pixelG = 0;
                    double pixelB = 0;

                    int StartY = y - ShortSide1;
                    int StartX = x - ShortSide2;

                    for (int FX = 0; FX < filterWidth; FX++)
                    {
                        for (int FY = 0; FY < filterHeight; FY++)
                        {
                            int xx = StartX + FX;
                            int yy = StartY + FY;

                            if (xx < 0)
                            {
                                xx = 0;
                            }


                            if (yy < 0)
                            {
                                yy = 0;
                            }

                            if (xx >= width)
                            {
                                xx = width - 1;
                            }


                            if (yy >= height)
                            {
                                yy = height - 1;
                            }

                            pixelR += WorkingImage[WorkingImage.Count - 1][0, yy, xx] * target.MatrixForm[FY, FX] * target.Multiplier;
                            pixelG += WorkingImage[WorkingImage.Count - 1][1, yy, xx] * target.MatrixForm[FY, FX] * target.Multiplier;
                            pixelB += WorkingImage[WorkingImage.Count - 1][2, yy, xx] * target.MatrixForm[FY, FX] * target.Multiplier;
                        }
                    }

                    result[0, y, x] = pixelR;
                    result[1, y, x] = pixelG;
                    result[2, y, x] = pixelB;
                }
            }
            WorkingImage.Add(result);
            RefreshImage();
            textBox4.Text = "" + WorkingImage.Count;
        }