CogColorSegmenterTool控件主要在颜色检测中使用。
1.CogColorSegmenterTool使用很简单,把颜色进行分离出来成为灰图(黑白二种)
步骤如下新增指定点或区域的颜色:
2.确认需要进行分离的区域(得到的图片为此区域图片)
3.得到的区域图片(进行各项检测使用)
4.在C#中的应用比较简单--应用控件进行编辑
1 tool_corlor = new CogColorSegmenterTool();
2 Form2 colorform=new Form2();
3 if (colorform.ShowDialog()==DialogResult.OK)
4 {
5 tool_corlor = colorform.tool_corlor;
6 tool_corlor.Run();
7 cogRecordDisplay1.Record = tool_corlor.CreateLastRunRecord().SubRecords[1];
8 }
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 using Cognex.VisionPro;
10 using Cognex.VisionPro.ColorSegmenter;
11 using Cognex.VisionPro.Display;
12 using Cognex.VisionPro.ImageFile;
13 using Cognex.VisionPro.ImageProcessing;
14 using Cognex.VisionPro.ToolBlock;
15
16 namespace visionpro_test
17 {
18 public partial class Form2 : Form
19 {
20 public Form2()
21 {
22 InitializeComponent();
23 }
24 public CogColorSegmenterTool tool_corlor = null;
25
26 private void button1_Click(object sender, EventArgs e)
27 {
28 this.DialogResult = DialogResult.OK;
29 tool_corlor = cogColorSegmenterEditV21.Subject;
30 this.Close();
31 }
32
33 private void cogColorSegmenterEditV21_Load(object sender, EventArgs e)
34 {
35
36 Bitmap A1 = new Bitmap(@"D:\AVI\12.JPG");
37 CogImage24PlanarColor ima3 = new CogImage24PlanarColor(A1);
38 cogColorSegmenterEditV21.Subject.InputImage = ima3;
39 }
40 }