Exemple #1
0
        public void MouseUp(Panel canvas, MouseButtonEventArgs e, Matrix screenToWorld)
        {
            if (_rectangle == null)
            {
                return;
            }

            _rectangle.IsSelected = true;
            _rectangle            = null;
        }
 public GLineUThresholdParas()
 {
     //初始化字段默认值
     Rectangle1   = new Rectangle1();
     deltaPoint   = new Point(0, 0);
     hv_MinGray   = 0;
     hv_MaxGray   = 255;
     TDLR         = 1;
     b            = 0;
     AngularPoint = false;
 }
Exemple #3
0
        private void btn_SelectROI_Click(object sender, EventArgs e)
        {
            DrawMode(true);                                                                                                //绘制模式开启
            Rectangle1 rectangle1 = Func_HalconFunction.DrawRectangle1(hWindow_Final1.hWindowControl.HalconWindow);        //画矩形

            DrawMode(false);                                                                                               //绘制模式关闭
            (transformation.line as GetLineUseThreshold).parameter.rectangle2 = Func_Mathematics.ToRectangle2(rectangle1); //ROI矩形赋值

            prepared = true;
            RunOnce();
        }
Exemple #4
0
        private void btn_SelectROI_Click(object sender, EventArgs e)
        {
            DrawMode(true);

            Rectangle1 rectangle1 = Func_HalconFunction.DrawRectangle1(hWindow_Final1.hWindowControl.HalconWindow);

            getRegionUseThreshold.parameter.rectangle2 = Func_Mathematics.ToRectangle2(rectangle1);

            DrawMode(false);
            prepared = true;
            RunOnce();
        }
        private void btn2_MouseEnter(object sender, MouseEventArgs e)
        {
            StackPanel1.Visibility = Visibility.Visible;
            StackPanel2.Visibility = Visibility.Hidden;
            StackPanel3.Visibility = Visibility.Hidden;
            StackPanel4.Visibility = Visibility.Hidden;
            czy_otwarta_pierwsza   = true;
            czy_otwarta_druga      = false;
            czy_otwarta_trzecia    = false;
            czy_otwarta_czwarta    = false;

            Rectangle1.BeginAnimation(WidthProperty, BorderAnimation1);
        }
Exemple #6
0
        public void MouseDown(Panel canvas, MouseButtonEventArgs e, Matrix screenToWorld)
        {
            Point p = e.GetPosition(canvas);

            p = screenToWorld.Transform(p);

            _rectangle        = new Rectangle1();
            _rectangle.Left   = p.X;
            _rectangle.Top    = p.Y;
            _rectangle.Right  = p.X;
            _rectangle.Bottom = p.Y;

            canvas.Children.Add(_rectangle);
        }
Exemple #7
0
        private void tsmi_Next_Click(object sender, EventArgs e)
        {
            DrawMode(true);                                                                                         //绘制模式开启
            Rectangle1 rectangle1 = Func_HalconFunction.DrawRectangle1(hWindow_Final1.hWindowControl.HalconWindow); //画矩形

            DrawMode(false);                                                                                        //绘制模式关闭
            HObject ho_Rectangle = Func_HalconFunction.GenRectangle1(rectangle1);                                   //创建矩形

            hWindow_Final1.DispObj(ho_Rectangle, "blue");                                                           //显示矩形

            GetLineUseThreshold line = new GetLineUseThreshold(new Threshold(Func_Mathematics.ToRectangle2(rectangle1)));

            getSetOfLines.AddLine(line);
        }
 //MouseEnter
 private void btn1_MouseEnter(object sender, MouseEventArgs e)
 {
     if (StackPanel1.Visibility == Visibility.Hidden)
     {
         StackPanel1.BeginAnimation(HeightProperty, DropDownAnimation);
         StackPanel1.BeginAnimation(OpacityProperty, DropDownOpacityAnimation);
         StackPanel1.Effect.BeginAnimation(OpacityProperty, DropDownOpacityAnimation);
     }
     StackPanel1.Visibility = Visibility.Visible;
     StackPanel2.Visibility = Visibility.Hidden;
     StackPanel3.Visibility = Visibility.Hidden;
     StackPanel4.Visibility = Visibility.Hidden;
     Rectangle1.BeginAnimation(WidthProperty, BorderAnimation1);
 }
Exemple #9
0
            static void Main()
            {
                Rectangle1 R = new Rectangle1();

                R.GetLB();
                Calculate(R);

                Console.WriteLine();

                Circle1 C = new Circle1();

                C.GetRadius();
                Calculate(C);

                Console.Read();
            }
Exemple #10
0
        /// <summary>
        /// Compares two instances of this object.
        /// </summary>
        /// <param name="Rectangle1">A Rectangle&lt;T&gt;.</param>
        /// <param name="Rectangle2">Another Rectangle&lt;T&gt;.</param>
        /// <returns>true|false</returns>
        public static Boolean operator ==(Rectangle <T> Rectangle1, Rectangle <T> Rectangle2)
        {
            // If both are null, or both are same instance, return true.
            if (Object.ReferenceEquals(Rectangle1, Rectangle2))
            {
                return(true);
            }

            // If one is null, but not both, return false.
            if (((Object)Rectangle1 == null) || ((Object)Rectangle2 == null))
            {
                return(false);
            }

            return(Rectangle1.Equals(Rectangle2));
        }
Exemple #11
0
    public bool TheyIntersect(Rectangle1 rectangle)
    {
        double firstLeftBorder  = this.TopLeftX;
        double firstTopBorder   = this.TopLeftY;
        double firstBotBorder   = firstTopBorder - this.Height;
        double firstRightBorder = firstLeftBorder + this.Width;

        double secondLeftBorder  = rectangle.TopLeftX;
        double secondTopBorder   = rectangle.TopLeftY;
        double secondBotBorder   = secondTopBorder - rectangle.Height;
        double secondRightBorder = secondLeftBorder + rectangle.Width;

        return(secondRightBorder >= firstLeftBorder &&
               secondLeftBorder <= firstRightBorder &&
               secondTopBorder >= firstBotBorder &&
               secondBotBorder <= firstTopBorder);
    }
Exemple #12
0
        private void btn_slg_ReDrowROI_Click(object sender, EventArgs e)
        {
            DrawMode(true);//绘制模式开启
            Rectangle1 rectangle1 = Func_Mathematics.ToRectangle1(slgLine.parameter.rectangle2);
            Rectangle2 rectangle2;

            if (rectangle1 != null)
            {
                rectangle1 = Func_HalconFunction.DrawRectangle1Mod(hWindow_Final1.hWindowControl.HalconWindow, rectangle1);//画矩形
                rectangle2 = Func_Mathematics.ToRectangle2(rectangle1);
            }
            else
            {
                rectangle2 = Func_HalconFunction.DrawRectangle2Mod(hWindow_Final1.hWindowControl.HalconWindow, slgLine.parameter.rectangle2);
            }
            DrawMode(false); //绘制模式关闭
            slgLine.parameter.rectangle2 = rectangle2;
            RunOnce();       //运行测试
        }
Exemple #13
0
        private void btn_DrawROIs_Click(object sender, EventArgs e)
        {
            getSetOfLines.RemoveAll();                                                                              //删除所有项
            hWindow_Final1.HobjectToHimage(ho_Image);                                                               //刷新图片
            hWindow_Final1.ContextMenuStrip = contextMenuStrip1;                                                    //启用右键菜单
            DrawMode(true);                                                                                         //绘制模式开启
            Rectangle1 rectangle1 = Func_HalconFunction.DrawRectangle1(hWindow_Final1.hWindowControl.HalconWindow); //画矩形

            DrawMode(false);                                                                                        //绘制模式关闭
            HObject ho_Rectangle = Func_HalconFunction.GenRectangle1(rectangle1);                                   //创建矩形

            hWindow_Final1.DispObj(ho_Rectangle, "blue");                                                           //显示矩形
            //创建该项
            GetLineUseThreshold line = new GetLineUseThreshold(new Threshold(Func_Mathematics.ToRectangle2(rectangle1)));

            getSetOfLines.AddLine(line);            //添加该项
            cmb_slg_SelectItem.SelectedItem = null; //
            slgLine = null;
        }
Exemple #14
0
        public static double Area(object[] shapes)
        {
            double area = 0;

            foreach (var shape in shapes)
            {
                if (shape is Rectangle1)
                {
                    Rectangle1 rectangle = (Rectangle1)shape;
                    area += rectangle.Width * rectangle.Height;
                }
                else
                {
                    Circle1 circle = (Circle1)shape;
                    area += circle.Radius * circle.Radius * Math.PI;
                }
            }

            return(area);
        }
Exemple #15
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            var compositor = Window.Current.Compositor;

            var rotationAnimation = compositor.CreateScalarKeyFrameAnimation();
            var linear            = compositor.CreateLinearEasingFunction();

            rotationAnimation.InsertKeyFrame(1.0f, 360, linear);
            rotationAnimation.Duration          = TimeSpan.FromSeconds(9);
            rotationAnimation.Target            = nameof(Rectangle1.Rotation);
            rotationAnimation.IterationBehavior = AnimationIterationBehavior.Forever;
            Rectangle1.CenterPoint = new Vector3((float)Rectangle1.Width / 2, (float)Rectangle1.Height / 2, 0);
            Rectangle2.CenterPoint = new Vector3((float)Rectangle2.Width / 2, (float)Rectangle2.Height / 2, 0);

            Rectangle1.StartAnimation(rotationAnimation);

            rotationAnimation.Duration = TimeSpan.FromSeconds(8);

            Rectangle2.StartAnimation(rotationAnimation);
        }
Exemple #16
0
 public static bool operator !=(Rect Rectangle1, Rect Rectangle2)
 {
     return(!Rectangle1.Equals(Rectangle2));
 }
 private void btn2_MouseLeave(object sender, MouseEventArgs e)
 {
     Rectangle1.BeginAnimation(WidthProperty, BorderAnimation2);
 }
Exemple #18
0
 public static bool operator ==(RECT Rectangle1, RECT Rectangle2)
 {
     return(Rectangle1.Equals(Rectangle2));
 }
Exemple #19
0
        private void btn_Draw_Click(object sender, EventArgs e)
        {
            hWindow_Final1.HobjectToHimage(ho_Image);//刷新
            TabPage tabPage = tabControl1.SelectedTab;

            if (tabPage != null)
            {
                if (tabPage.Name == "tp_Threshold")
                {
                    if (!(line is GetLineUseThreshold))
                    {
                        line = new GetLineUseThreshold();
                        data = line;
                    }
                    if (chk_Angle.Checked)
                    {
                        DrawMode(true);                                                                                                                      //绘制模式开启
                        (line as GetLineUseThreshold).parameter.rectangle2 = Func_HalconFunction.DrawRectangle2(hWindow_Final1.hWindowControl.HalconWindow); //画矩形
                        DrawMode(false);                                                                                                                     //绘制模式关闭
                    }
                    else
                    {
                        DrawMode(true);                                                                                         //绘制模式开启
                        Rectangle1 rectangle1 = Func_HalconFunction.DrawRectangle1(hWindow_Final1.hWindowControl.HalconWindow); //画矩形
                        DrawMode(false);                                                                                        //绘制模式关闭
                        (line as GetLineUseThreshold).parameter.rectangle2 = Func_Mathematics.ToRectangle2(rectangle1);         //ROI矩形赋值
                    }
                    sign = LineStyle.灰度抓取;
                }
                if (tabPage.Name == "tp_Measure_Pos")
                {
                    if (!(line is GetLineUseMeasure_Pos))//?不是GetLineUseMeasure_Pos
                    {
                        line = new GetLineUseMeasure_Pos();
                        data = line;
                    }
                    DrawMode(true);                                                                                                                   //绘制模式开启
                    (line as GetLineUseMeasure_Pos).parameter.line.SetLine(Func_HalconFunction.DrawLine(hWindow_Final1.hWindowControl.HalconWindow)); //画ROI线
                    DrawMode(false);                                                                                                                  //绘制模式关闭
                    if (!chk_Angle.Checked)
                    {
                        double dx = (line as GetLineUseMeasure_Pos).parameter.line.hv_Column1 - (line as GetLineUseMeasure_Pos).parameter.line.hv_Column2;
                        double dy = (line as GetLineUseMeasure_Pos).parameter.line.hv_Row1 - (line as GetLineUseMeasure_Pos).parameter.line.hv_Row2;
                        double mx = ((line as GetLineUseMeasure_Pos).parameter.line.hv_Column1 + (line as GetLineUseMeasure_Pos).parameter.line.hv_Column2) / 2;
                        double my = ((line as GetLineUseMeasure_Pos).parameter.line.hv_Row1 + (line as GetLineUseMeasure_Pos).parameter.line.hv_Row2) / 2;
                        if (Math.Abs(dx) > Math.Abs(dy))//?横向距离长
                        {
                            (line as GetLineUseMeasure_Pos).parameter.line.hv_Row1 = (int)my;
                            (line as GetLineUseMeasure_Pos).parameter.line.hv_Row2 = (int)my;
                        }
                        else//?纵向距离长
                        {
                            (line as GetLineUseMeasure_Pos).parameter.line.hv_Column1 = (int)mx;
                            (line as GetLineUseMeasure_Pos).parameter.line.hv_Column2 = (int)mx;
                        }
                    }
                    sign = LineStyle.边缘检测;
                }
                if (tabPage.Name == "tp_Canny")
                {
                    if (!(line is GetLineUseCanny))//?不是GetLineUseMeasure_Pos
                    {
                        line = new GetLineUseCanny();
                        data = line;
                    }
                    if (chk_Angle.Checked)
                    {
                        DrawMode(true);                                                                                                                  //绘制模式开启
                        (line as GetLineUseCanny).parameter.rectangle2 = Func_HalconFunction.DrawRectangle2(hWindow_Final1.hWindowControl.HalconWindow); //画矩形
                        DrawMode(false);                                                                                                                 //绘制模式关闭
                    }
                    else
                    {
                        DrawMode(true);                                                                                         //绘制模式开启
                        Rectangle1 rectangle1 = Func_HalconFunction.DrawRectangle1(hWindow_Final1.hWindowControl.HalconWindow); //画矩形
                        DrawMode(false);                                                                                        //绘制模式关闭
                        (line as GetLineUseCanny).parameter.rectangle2 = Func_Mathematics.ToRectangle2(rectangle1);             //ROI矩形赋值
                    }
                    sign = LineStyle.边缘拟合;
                }

                if (tabPage.Name == "tp_Metrology")
                {
                    if (!(line is GetLineUseMetrology))
                    {
                        line = new GetLineUseMetrology();
                        data = line;
                    }

                    DrawMode(true);  //绘制模式开启
                    (line as GetLineUseMetrology).parameter.Line = Func_HalconFunction.DrawLine(hWindow_Final1.hWindowControl.HalconWindow);
                    DrawMode(false); //绘制模式关闭

                    sign = LineStyle.直线拟合;
                }
                prepared = true;
                RunOnce();
            }
        }
        public DXEventManager3DSample()
        {
            InitializeComponent();


            Box1Visual3D.SetName("Box1Visual3D");
            BoxesGroupVisual3D.SetName("BoxesGroupVisual3D");
            Box2Visual3D.SetName("Box2Visual3D");
            Box3Visual3D.SetName("Box3Visual3D");
            Box4Visual3D.SetName("Box4Visual3D");
            Line1.SetName("Line1");
            Line2.SetName("Line2");
            Rectangle1.SetName("Rectangle1");


            var meshGeometry3D = new Ab3d.Meshes.SphereMesh3D(centerPosition: new Point3D(0, 0, 0), radius: 5, segments: 20, generateTextureCoordinates: false).Geometry;

            // The following method prepare InstanceData array with data for each instance (WorldMatrix and Color)
            InstanceData[] instancedData = DXEnginePerformance.InstancedMeshGeometry3DTest.CreateInstancesData(center: new Point3D(0, 0, 0),
                                                                                                               size: new Size3D(200, 50, 50),
                                                                                                               modelScaleFactor: 1,
                                                                                                               xCount: 10,
                                                                                                               yCount: 3,
                                                                                                               zCount: 3,
                                                                                                               useTransparency: false);


            // Create InstancedGeometryVisual3D with selected meshGeometry and InstancesData
            _instancedMeshGeometryVisual3D = new InstancedMeshGeometryVisual3D(meshGeometry3D);
            _instancedMeshGeometryVisual3D.InstancesData = instancedData;
            _instancedMeshGeometryVisual3D.SetName("InstancedMeshGeometryVisual3D");
            _instancedMeshGeometryVisual3D.Transform = new TranslateTransform3D(0, 50, 0);

            MainViewport3D.Children.Add(_instancedMeshGeometryVisual3D);

            _selectedInstanceIndex = -1;


            var model3DGroup = new Model3DGroup();

            model3DGroup.SetName("Model3DGroup");

            var frozenModel3DGroup = new Model3DGroup();

            frozenModel3DGroup.SetName("FrozenModel3DGroup");

            var box1Material = new DiffuseMaterial(Brushes.LightPink);
            var box2Material = new DiffuseMaterial(Brushes.LightCyan);

            var boxModel3D = Ab3d.Models.Model3DFactory.CreateBox(new Point3D(-100, 2, 25), new Size3D(60, 4, 50), box2Material);

            frozenModel3DGroup.Children.Add(boxModel3D);

            var pyramidModel3D = Ab3d.Models.Model3DFactory.CreatePyramid(new Point3D(-100, 2, 20), new Size3D(20, 20, 20), box2Material);

            frozenModel3DGroup.Children.Add(pyramidModel3D);

            for (int i = 0; i < 5; i++)
            {
                var geometryModel3D = new GeometryModel3D(meshGeometry3D, box1Material);
                geometryModel3D.Transform = new TranslateTransform3D(-130 + i * 15, 5, 80);
                geometryModel3D.SetName("GroupedSphere_" + i.ToString());

                model3DGroup.Children.Add(geometryModel3D);

                geometryModel3D           = new GeometryModel3D(meshGeometry3D, box2Material);
                geometryModel3D.Transform = new TranslateTransform3D(-130 + i * 15, 10, 50);
                geometryModel3D.SetName("FrozenGroupedSphere_" + i.ToString());

                frozenModel3DGroup.Children.Add(geometryModel3D);
            }


            frozenModel3DGroup.Freeze();

            MainViewport3D.Children.Add(model3DGroup.CreateModelVisual3D());
            MainViewport3D.Children.Add(frozenModel3DGroup.CreateModelVisual3D());

            _dxEventManager3D = new DXEventManager3D(MainDXViewportView);

            RegisterEventSource(Box1Visual3D);
            RegisterEventSource(BoxesGroupVisual3D);
            RegisterEventSource(Line1);
            RegisterEventSource(Line2);
            RegisterEventSource(Rectangle1);
            RegisterEventSource(_instancedMeshGeometryVisual3D);

            RegisterEventSource(model3DGroup);
            RegisterEventSource(frozenModel3DGroup);


            // Prevent TransparentPlaneVisual3D to be used by hit-testing
            _dxEventManager3D.RegisterExcludedVisual3D(TransparentPlaneVisual3D);


            this.PreviewMouseMove += delegate(object sender, MouseEventArgs args)
            {
                var position = args.GetPosition(this);
                MousePositionTextBlock.Text = $"Mouse pos: {position.X:0} {position.Y:0}";
            };

            this.PreviewMouseDown += delegate(object sender, MouseButtonEventArgs e)
            {
                var position = e.GetPosition(this);
                if (position == _lastMouseDownPosition)
                {
                    return;
                }

                System.Diagnostics.Debug.WriteLine("Mouse position: " + position.ToString());

                _lastMouseDownPosition = position;
            };


            // IMPORTANT:
            // It is very important to call Dispose method on DXSceneView after the control is not used any more (see help file for more info)
            this.Unloaded += (sender, args) => MainDXViewportView.Dispose();
        }
Exemple #21
0
        public bool RunThresholdTest_new(ExecuteBuffer _executeBuffer, out ExecuteBuffer outexecutebuffer, out string result_info, Dictionary <int, PointName> Pointlist)
        {
            outexecutebuffer = _executeBuffer;
            result_info      = "";
            double  x_bu = 0;
            double  y_bu = 0;
            HObject image1, image2, image3, image4, image5, image6, image7, image8, image9;

            HOperatorSet.GenEmptyObj(out image1);
            HOperatorSet.GenEmptyObj(out image2);
            HOperatorSet.GenEmptyObj(out image3);
            HOperatorSet.GenEmptyObj(out image4);
            HOperatorSet.GenEmptyObj(out image5);
            HOperatorSet.GenEmptyObj(out image6);
            HOperatorSet.GenEmptyObj(out image7);
            HOperatorSet.GenEmptyObj(out image8);
            HOperatorSet.GenEmptyObj(out image9);
            int number_check = Convert.ToInt32(this.textBox_dian.Text.ToString());

            if (!Pointlist.ContainsKey(number_check))
            {
                MessageBox.Show("拼图数据:  输入为空,其中没有点位");
                result_info = "拼图数据:  输入为空,其中没有点位";
            }
            else
            {
                if (Pointlist[number_check].点X.TupleLength() > 0)
                {
                    x_bu = Pointlist[number_check].点X[0];
                    y_bu = Pointlist[number_check].点Y[0];
                }
            }

            double X_shu = (Convert.ToDouble(this.textBox_x.Text.ToString())) / Convert.ToDouble(this.textBox_bi.Text.ToString()) + Convert.ToDouble(this.textBox_x.Text.ToString()) * x_bu;
            double Y_shu = (Convert.ToDouble(this.textBox_y.Text.ToString()) + y_bu) / Convert.ToDouble(this.textBox_bi.Text.ToString()) + Convert.ToDouble(this.textBox_y.Text.ToString()) * y_bu;

            if (!_executeBuffer.imageBuffer.ContainsKey(this.Input_image1.SelectedItem.ToString() + ".img"))
            {
                MessageBox.Show("二值化处理: 输入图像1已经不存在,请重置设置输入图像");
                result_info = " 二值化处理: 输入图像1已经不存在,请重置设置输入图像";
                return(false);
            }
            if (_executeBuffer.imageBuffer[this.Input_image1.SelectedItem.ToString() + ".img"] == null)
            {
                MessageBox.Show("二值化处理: image1参数为空或者未赋值");
                result_info = " 二值化处理: 输入图像1已经不存在,请重置设置输入图像";
                return(false);
            }

            if (!_executeBuffer.imageBuffer.ContainsKey(this.Input_image2.SelectedItem.ToString() + ".img"))
            {
                MessageBox.Show("二值化处理: 输入图像2已经不存在,请重置设置输入图像");
                result_info = " 二值化处理: 输入图像2已经不存在,请重置设置输入图像";
                return(false);
            }
            if (_executeBuffer.imageBuffer[this.Input_image2.SelectedItem.ToString() + ".img"] == null)
            {
                MessageBox.Show("二值化处理: image2参数为空或者未赋值");
                result_info = " 二值化处理: 输入图像2已经不存在,请重置设置输入图像";
                return(false);
            }
            if (!_executeBuffer.imageBuffer.ContainsKey(this.Input_image3.SelectedItem.ToString() + ".img"))
            {
                MessageBox.Show("二值化处理: 输入图像3已经不存在,请重置设置输入图像");
                result_info = " 二值化处理: 输入图像3已经不存在,请重置设置输入图像";
                return(false);
            }
            if (_executeBuffer.imageBuffer[this.Input_image3.SelectedItem.ToString() + ".img"] == null)
            {
                MessageBox.Show("二值化处理: image3参数为空或者未赋值");
                result_info = " 二值化处理: 输入图像3已经不存在,请重置设置输入图像";
                return(false);
            }
            if (!_executeBuffer.imageBuffer.ContainsKey(this.Input_image4.SelectedItem.ToString() + ".img"))
            {
                MessageBox.Show("二值化处理: 输入图像4已经不存在,请重置设置输入图像");
                result_info = " 二值化处理: 输入图像4已经不存在,请重置设置输入图像";
                return(false);
            }
            if (_executeBuffer.imageBuffer[this.Input_image4.SelectedItem.ToString() + ".img"] == null)
            {
                MessageBox.Show("二值化处理: image4参数为空或者未赋值");
                result_info = " 二值化处理: 输入图像4已经不存在,请重置设置输入图像";
                return(false);
            }
            if (!_executeBuffer.imageBuffer.ContainsKey(this.Input_image5.SelectedItem.ToString() + ".img"))
            {
                MessageBox.Show("二值化处理: 输入图像5已经不存在,请重置设置输入图像");
                result_info = " 二值化处理: 输入图像5已经不存在,请重置设置输入图像";
                return(false);
            }
            if (_executeBuffer.imageBuffer[this.Input_image5.SelectedItem.ToString() + ".img"] == null)
            {
                MessageBox.Show("二值化处理: image5参数为空或者未赋值");
                result_info = " 二值化处理: 输入图像5已经不存在,请重置设置输入图像";
                return(false);
            }
            if (!_executeBuffer.imageBuffer.ContainsKey(this.Input_image6.SelectedItem.ToString() + ".img"))
            {
                MessageBox.Show("二值化处理: 输入图像6已经不存在,请重置设置输入图像");
                result_info = " 二值化处理: 输入图像6已经不存在,请重置设置输入图像";
                return(false);
            }
            if (_executeBuffer.imageBuffer[this.Input_image6.SelectedItem.ToString() + ".img"] == null)
            {
                MessageBox.Show("二值化处理: image6参数为空或者未赋值");
                result_info = " 二值化处理: 输入图像6已经不存在,请重置设置输入图像";
                return(false);
            }
            if (!_executeBuffer.imageBuffer.ContainsKey(this.Input_image7.SelectedItem.ToString() + ".img"))
            {
                MessageBox.Show("二值化处理: 输入图像7已经不存在,请重置设置输入图像");
                result_info = " 二值化处理: 输入图像7已经不存在,请重置设置输入图像";
                return(false);
            }
            if (_executeBuffer.imageBuffer[this.Input_image7.SelectedItem.ToString() + ".img"] == null)
            {
                MessageBox.Show("二值化处理: image7参数为空或者未赋值");
                result_info = " 二值化处理: 输入图像7已经不存在,请重置设置输入图像";
                return(false);
            }
            if (!_executeBuffer.imageBuffer.ContainsKey(this.Input_image8.SelectedItem.ToString() + ".img"))
            {
                MessageBox.Show("二值化处理: 输入图像8已经不存在,请重置设置输入图像");
                result_info = " 二值化处理: 输入图像8已经不存在,请重置设置输入图像";
                return(false);
            }
            if (_executeBuffer.imageBuffer[this.Input_image8.SelectedItem.ToString() + ".img"] == null)
            {
                MessageBox.Show("二值化处理: image8参数为空或者未赋值");
                result_info = " 二值化处理: 输入图像8已经不存在,请重置设置输入图像";
                return(false);
            }
            if (!_executeBuffer.imageBuffer.ContainsKey(this.Input_image9.SelectedItem.ToString() + ".img"))
            {
                MessageBox.Show("二值化处理: 输入图像9已经不存在,请重置设置输入图像");
                result_info = " 二值化处理: 输入图像9已经不存在,请重置设置输入图像";
                return(false);
            }
            if (_executeBuffer.imageBuffer[this.Input_image9.SelectedItem.ToString() + ".img"] == null)
            {
                MessageBox.Show("二值化处理: image9参数为空或者未赋值");
                result_info = " 二值化处理: 输入图像9已经不存在,请重置设置输入图像";
                return(false);
            }
            string comboBox_imageoutname = this.Output_image.Text.ToString() + ".img";

            if (_executeBuffer.imageBuffer[comboBox_imageoutname] != null)
            {
                if (_executeBuffer.imageBuffer[comboBox_imageoutname].IsInitialized())
                {
                    _executeBuffer.imageBuffer[comboBox_imageoutname].Dispose();
                }
            }
            HOperatorSet.CopyImage(_executeBuffer.imageBuffer[this.Input_image1.SelectedItem.ToString() + ".img"], out image1);
            HOperatorSet.CopyImage(_executeBuffer.imageBuffer[this.Input_image2.SelectedItem.ToString() + ".img"], out image2);
            HOperatorSet.CopyImage(_executeBuffer.imageBuffer[this.Input_image3.SelectedItem.ToString() + ".img"], out image3);
            HOperatorSet.CopyImage(_executeBuffer.imageBuffer[this.Input_image4.SelectedItem.ToString() + ".img"], out image4);
            HOperatorSet.CopyImage(_executeBuffer.imageBuffer[this.Input_image5.SelectedItem.ToString() + ".img"], out image5);
            HOperatorSet.CopyImage(_executeBuffer.imageBuffer[this.Input_image6.SelectedItem.ToString() + ".img"], out image6);
            HOperatorSet.CopyImage(_executeBuffer.imageBuffer[this.Input_image7.SelectedItem.ToString() + ".img"], out image7);
            HOperatorSet.CopyImage(_executeBuffer.imageBuffer[this.Input_image8.SelectedItem.ToString() + ".img"], out image8);
            HOperatorSet.CopyImage(_executeBuffer.imageBuffer[this.Input_image9.SelectedItem.ToString() + ".img"], out image9);

            /*
             * image1 = _executeBuffer.imageBuffer[this.Input_image1.SelectedItem.ToString() + ".img"];
             * image2 = _executeBuffer.imageBuffer[this.Input_image2.SelectedItem.ToString() + ".img"];
             * image3 = _executeBuffer.imageBuffer[this.Input_image3.SelectedItem.ToString() + ".img"];
             * image4 = _executeBuffer.imageBuffer[this.Input_image4.SelectedItem.ToString() + ".img"];
             * image5 = _executeBuffer.imageBuffer[this.Input_image5.SelectedItem.ToString() + ".img"];
             * image6 = _executeBuffer.imageBuffer[this.Input_image6.SelectedItem.ToString() + ".img"];
             * image7 = _executeBuffer.imageBuffer[this.Input_image7.SelectedItem.ToString() + ".img"];
             * image8 = _executeBuffer.imageBuffer[this.Input_image8.SelectedItem.ToString() + ".img"];
             * image9 = _executeBuffer.imageBuffer[this.Input_image9.SelectedItem.ToString() + ".img"];
             */
            HTuple  width, height, width123, height123;
            HObject Rectangle1, Mask1, ImagePart1, Mask2, ImagePart2, imagex, imagey, imagez, imagea, ho_TiledImage;

            HOperatorSet.GenEmptyObj(out Rectangle1);
            HOperatorSet.GenEmptyObj(out Mask1);
            HOperatorSet.GenEmptyObj(out ImagePart1);
            HOperatorSet.GenEmptyObj(out Mask2);
            HOperatorSet.GenEmptyObj(out ImagePart2);
            HOperatorSet.GenEmptyObj(out imagex);
            HOperatorSet.GenEmptyObj(out imagey);
            HOperatorSet.GenEmptyObj(out imagez);
            HOperatorSet.GenEmptyObj(out imagea);
            HOperatorSet.GenEmptyObj(out ho_TiledImage);


            HOperatorSet.GetImageSize(image1, out width, out height);
            HOperatorSet.GenRectangle1(out Rectangle1, 0, 0, height, X_shu);


            HOperatorSet.ReduceDomain(image1, Rectangle1, out Mask1);
            HOperatorSet.CropDomain(Mask1, out ImagePart1);
            HOperatorSet.ReduceDomain(image2, Rectangle1, out Mask2);
            HOperatorSet.CropDomain(Mask2, out ImagePart2);
            HOperatorSet.GetImageSize(ImagePart1, out width123, out height123);
            HOperatorSet.GenEmptyObj(out imagex);
            HOperatorSet.ConcatObj(imagex, ImagePart1, out imagex);
            HOperatorSet.ConcatObj(imagex, ImagePart2, out imagex);
            HOperatorSet.ConcatObj(imagex, image3, out imagex);
            HOperatorSet.GenEmptyObj(out ho_TiledImage);
            HOperatorSet.TileImagesOffset(imagex, out ho_TiledImage, ((new HTuple(0)).TupleConcat(
                                                                          0)).TupleConcat(0), (((new HTuple(0)).TupleConcat(width123))).TupleConcat(
                                              width123 + width123), ((new HTuple(-1)).TupleConcat(-1)).TupleConcat(-1),
                                          ((new HTuple(-1)).TupleConcat(-1)).TupleConcat(-1), ((new HTuple(-1)).TupleConcat(
                                                                                                   -1)).TupleConcat(-1), ((new HTuple(-1)).TupleConcat(-1)).TupleConcat(-1),
                                          (width123 + width123) + width, height);
            //  image1.Dispose();
            //   image2.Dispose();
            Mask1.Dispose();
            Mask2.Dispose();
            //  image3.Dispose();

            ImagePart2.Dispose();
            ImagePart1.Dispose();
            imagex.Dispose();

            HTuple  width456, height456;
            HObject ho_TiledImage1, Mask4, Mask5, ImagePart4, ImagePart5;

            HOperatorSet.ReduceDomain(image4, Rectangle1, out Mask4);
            HOperatorSet.CropDomain(Mask4, out ImagePart4);
            HOperatorSet.ReduceDomain(image5, Rectangle1, out Mask5);
            HOperatorSet.CropDomain(Mask5, out ImagePart5);
            HOperatorSet.GetImageSize(ImagePart4, out width456, out height456);
            HOperatorSet.GenEmptyObj(out imagey);
            HOperatorSet.ConcatObj(imagey, ImagePart4, out imagey);
            HOperatorSet.ConcatObj(imagey, ImagePart5, out imagey);
            HOperatorSet.ConcatObj(imagey, image6, out imagey);
            HOperatorSet.GenEmptyObj(out ho_TiledImage1);
            HOperatorSet.TileImagesOffset(imagey, out ho_TiledImage1, ((new HTuple(0)).TupleConcat(
                                                                           0)).TupleConcat(0), (((new HTuple(0)).TupleConcat(width456))).TupleConcat(
                                              width456 + width456), ((new HTuple(-1)).TupleConcat(-1)).TupleConcat(-1),
                                          ((new HTuple(-1)).TupleConcat(-1)).TupleConcat(-1), ((new HTuple(-1)).TupleConcat(
                                                                                                   -1)).TupleConcat(-1), ((new HTuple(-1)).TupleConcat(-1)).TupleConcat(-1),
                                          (width456 + width456) + width, height);
            Mask4.Dispose();
            Mask5.Dispose();
            ImagePart4.Dispose();
            ImagePart5.Dispose();
            imagey.Dispose();
            //  image4.Dispose();
            //  image5.Dispose();
            //  image6.Dispose();
            HTuple  width789, height789;
            HObject ho_TiledImage2, Mask7, Mask8, ImagePart7, ImagePart8;

            HOperatorSet.ReduceDomain(image7, Rectangle1, out Mask7);
            HOperatorSet.CropDomain(Mask7, out ImagePart7);
            HOperatorSet.ReduceDomain(image8, Rectangle1, out Mask8);
            HOperatorSet.CropDomain(Mask8, out ImagePart8);
            HOperatorSet.GetImageSize(ImagePart8, out width789, out height789);
            HOperatorSet.GenEmptyObj(out imagez);
            HOperatorSet.ConcatObj(imagez, ImagePart7, out imagez);
            HOperatorSet.ConcatObj(imagez, ImagePart8, out imagez);
            HOperatorSet.ConcatObj(imagez, image9, out imagez);
            HOperatorSet.GenEmptyObj(out ho_TiledImage2);
            HOperatorSet.TileImagesOffset(imagez, out ho_TiledImage2, ((new HTuple(0)).TupleConcat(
                                                                           0)).TupleConcat(0), (((new HTuple(0)).TupleConcat(width789))).TupleConcat(
                                              width789 + width789), ((new HTuple(-1)).TupleConcat(-1)).TupleConcat(-1),
                                          ((new HTuple(-1)).TupleConcat(-1)).TupleConcat(-1), ((new HTuple(-1)).TupleConcat(
                                                                                                   -1)).TupleConcat(-1), ((new HTuple(-1)).TupleConcat(-1)).TupleConcat(-1),
                                          (width789 + width789) + width, height);

            Mask8.Dispose();
            Mask7.Dispose();
            imagez.Dispose();
            // image7.Dispose();
            //image8.Dispose();
            // image9.Dispose();
            ImagePart7.Dispose();
            ImagePart8.Dispose();

            Rectangle1.Dispose();
            HTuple  widtha3, heighta3, widthnew123, heightnew123;
            HObject Rectangle2, Mask11, ImagePart11, Mask22, ImagePart22, ho_TiledImage3;

            HOperatorSet.GenEmptyObj(out Rectangle2);
            HOperatorSet.GetImageSize(ho_TiledImage2, out widtha3, out heighta3);
            HOperatorSet.GenRectangle1(out Rectangle2, 0, 0, Y_shu, widtha3);

            HOperatorSet.ReduceDomain(ho_TiledImage, Rectangle2, out Mask11);
            HOperatorSet.CropDomain(Mask11, out ImagePart11);

            HOperatorSet.ReduceDomain(ho_TiledImage1, Rectangle2, out Mask22);
            HOperatorSet.CropDomain(Mask22, out ImagePart22);
            Rectangle2.Dispose();
            Mask11.Dispose();
            Mask22.Dispose();
            HOperatorSet.GetImageSize(ImagePart22, out widthnew123, out heightnew123);
            HOperatorSet.GenEmptyObj(out imagea);
            HOperatorSet.ConcatObj(imagea, ImagePart11, out imagea);
            HOperatorSet.ConcatObj(imagea, ImagePart22, out imagea);
            HOperatorSet.ConcatObj(imagea, ho_TiledImage2, out imagea);
            ImagePart11.Dispose();
            ImagePart22.Dispose();
            ho_TiledImage.Dispose();
            ho_TiledImage1.Dispose();
            ho_TiledImage2.Dispose();
            image1.Dispose();
            image2.Dispose();
            image3.Dispose();
            image4.Dispose();
            image5.Dispose();
            image6.Dispose();
            image7.Dispose();
            image8.Dispose();
            image9.Dispose();
            HOperatorSet.GenEmptyObj(out ho_TiledImage3);

            HOperatorSet.TileImagesOffset(imagea, out ho_TiledImage3, (((new HTuple(0)).TupleConcat(
                                                                            heightnew123))).TupleConcat(heightnew123 + heightnew123), ((new HTuple(0)).TupleConcat(
                                                                                                                                           0)).TupleConcat(0), ((new HTuple(-1)).TupleConcat(-1)).TupleConcat(-1), (
                                              (new HTuple(-1)).TupleConcat(-1)).TupleConcat(-1), ((new HTuple(-1)).TupleConcat(
                                                                                                      -1)).TupleConcat(-1), ((new HTuple(-1)).TupleConcat(-1)).TupleConcat(-1),
                                          widtha3, (heightnew123 + heightnew123) + height);


            _executeBuffer.imageBuffer[comboBox_imageoutname] = ho_TiledImage3;
            outexecutebuffer = _executeBuffer;


            outexecutebuffer = _executeBuffer;
            result_info      = " 拼图: 完成";

            imagea.Dispose();

            return(true);
        }
Exemple #22
0
 public static bool operator ==(UserRect Rectangle1, UserRect Rectangle2)
 {
     return(Rectangle1.Equals(Rectangle2));
 }