WIL説明書(.NET)  3.1.0
2値ブローブ解析

濃淡画像を2値化して、2値ブローブ解析し、2つのブローブの重心間の距離を計測する例です。


プレビュー:

Step2.Blob.Preview.2.png
2値ブローブ解析結果
Step2.Blob.Preview.3.png
2点間の距離

ワークフロー:

Step2.Blob.Component.1.png
Step2.Blob.Component.2.png
Step2.Blob.Component.3.png

ソースコード:
1 Option Strict Off
2 Option Explicit On
3 
4 Imports fvalgcli
5 Imports System
6 Imports System.Collections.Generic
7 Imports System.ComponentModel
8 Imports System.Drawing
9 Imports System.Globalization
10 Imports System.Reflection
11 Imports System.Runtime.Serialization
12 Imports System.Security.Permissions
13 Imports System.Text
14 Imports System.Windows.Forms
15 
16 Namespace FVIL.Parser
17 
18  <System.SerializableAttribute(), _
19  System.ComponentModel.TypeConverterAttribute(GetType(System.ComponentModel.ExpandableObjectConverter))> _
20  Partial Public Class ParserNodeUser
21  Inherits FVIL.Parser.ParserNodeUnit
22 
23  Public Overrides Sub Execute(ByVal sender As Object, ByVal e As System.EventArgs)
24  Dim target1_out0 As FVIL.Data.CFviImage = New FVIL.Data.CFviImage(320, 240, FVIL.ImageType.UC8, 1)
25  Dim target2_out0 As FVIL.Data.CFviImage = New FVIL.Data.CFviImage(320, 240, FVIL.ImageType.BIN, 1)
26  Dim target3_out0 As FVIL.Blob.CFviBlobList = New FVIL.Blob.CFviBlobList
27  Dim target4_out0 As FVIL.Blob.CFviBlobData = New FVIL.Blob.CFviBlobData
28  Dim target4_out1 As FVIL.Data.CFviPoint = New FVIL.Data.CFviPoint(59.94997843898232, 72.105648986632175)
29  Dim target4_out2 As Integer = 82
30  Dim target4_out3 As Integer = 94
31  Dim target5_out0 As FVIL.Blob.CFviBlobData = New FVIL.Blob.CFviBlobData
32  Dim target5_out1 As FVIL.Data.CFviPoint = New FVIL.Data.CFviPoint(202.01071237279058, 181.78628816282807)
33  Dim target5_out2 As Integer = 114
34  Dim target5_out3 As Integer = 55
35  Dim target6_out0 As Double = 179.47449605977764
36 
37  '画像#1
38  target1_out0 = CType(ParserInfo,FVIL.Parser.IDataObject(Of FVIL.Data.CFviImage)).Infos(0).Data
39 
40  '2値化#1
41  Dim target2 As FVIL.Conversion.CFviBinarizeDiscrimination = New FVIL.Conversion.CFviBinarizeDiscrimination
42  target2.SrcImages(0) = target1_out0
43  target2.DstImages(0) = target2_out0
44  target2.Execute
45 
46  '2値ブローブ解析#1
47  Dim target3 As FVIL.Blob.CFviBlob = New FVIL.Blob.CFviBlob
48  target3.SrcImages(0) = target2_out0
49  target3.ContinueOption = FVIL.Blob.ContinueOption.None
50  target3.OriginMode = FVIL.OriginMode.Image
51  target3.Offset = New System.Drawing.Point(0, 0)
52  target3.Param.KeepResultsAfterOverflow = false
53  target3.Param.PrecalcFeatures = FVIL.Blob.FeatureFlag.None
54  target3.Param.Neighborhood = FVIL.Blob.Neighborhood.Four
55  target3.Param.ColorMode = FVIL.Blob.ObjectColor.WhiteFG_BlackBG
56  target3.Param.MaxRows = 0
57  target3.Param.MaxBlobs = 0UI
58  target3.Param.MaxRuns = 0UI
59  target3.Execute
60  Dim target3_filters As System.Collections.Generic.List(Of FVIL.Blob.CFviBlobFilterRange) = _
61  New System.Collections.Generic.List(Of FVIL.Blob.CFviBlobFilterRange)
62  target3_filters.Add(New FVIL.Blob.CFviBlobFilterRange(FVIL.Blob.FeatureType.RECT1AREA, 1000, 4294967295))
63  target3_out0 = target3.Result.GetBlobList(target3_filters)
64 
65  'ブローブデータ#1
66  target4_out0.CopyFrom(target3_out0(1))
67  target4_out1 = target4_out0.Center
68  target4_out2 = target4_out0.Xdiff
69  target4_out3 = target4_out0.Ydiff
70 
71  'ブローブデータ#2
72  target5_out0.CopyFrom(target3_out0(4))
73  target5_out1 = target5_out0.Center
74  target5_out2 = target5_out0.Xdiff
75  target5_out3 = target5_out0.Ydiff
76 
77  '距離(2点間)#1
78  Dim target6_points As FVIL.Data.CFviPoint = New FVIL.Data.CFviPoint(1) {}
79  target6_points.Add(target5_out1)
80  target6_points.Add(target4_out1)
81  target6_out0 = FVIL.Caliper.[Function].Distance(target6_points)
82  End Sub
83  End Class
84 End Namespace

Documentation copyright © 2008 FAST Corporation. [B-001864]
Generated on 2024年10月10日(木) 10時07分53秒 for WIL説明書(.NET) by doxygen 1.8.11