Is there a way to learn both the CLASS and the ID for a BLOB clicked on by the USER?
All --
The IMAGE-PRO PLUS SUBROUTINE below will return the ID for the BLOB that is clicked on by the user.
If there is more than one CLASS within the COUNT / SIZE, there can be more than one BLOB with the same ID.
Is there a way to learn both the CLASS and the ID for a BLOB clicked on by the USER?
Thanks.
-- Matt
********************************************************************
Sub zzz()
'Declare required variables
Dim MyPoint1 As POINTAPI
Dim MyDocID1 As Integer
Dim MyBlobID1 As Long
Debug.Print Now
'Ask the user to select an object on the original image
MyDocID1 = _
IpDocClick _
( _
"Please CLICK within the INCLUSIONS you want to" & _
vbCr & vbCr & _
"ACCEPT" & _
vbCr & vbCr & _
"Press CONTINUE to complete this operation!", _
MyPoint1 _
)
Debug.Print "MyDocID1 = " & Str(MyDocID1)
'Determine which blob the point was within
MyBlobID1 = IpBlbHitTest (MyPoint1.X, MyPoint1.Y)
Debug.Print "MyBlobID1 = " & Str(MyBlobID1)
'Error trap
If ( Not(MyDocID1 > -1 And MyBlobID1 > -1) ) Then
'Jump to the end of the subroutine
GoTo MYENDER
End If
MYENDER:
End Sub
The IMAGE-PRO PLUS SUBROUTINE below will return the ID for the BLOB that is clicked on by the user.
If there is more than one CLASS within the COUNT / SIZE, there can be more than one BLOB with the same ID.
Is there a way to learn both the CLASS and the ID for a BLOB clicked on by the USER?
Thanks.
-- Matt
********************************************************************
Sub zzz()
'Declare required variables
Dim MyPoint1 As POINTAPI
Dim MyDocID1 As Integer
Dim MyBlobID1 As Long
Debug.Print Now
'Ask the user to select an object on the original image
MyDocID1 = _
IpDocClick _
( _
"Please CLICK within the INCLUSIONS you want to" & _
vbCr & vbCr & _
"ACCEPT" & _
vbCr & vbCr & _
"Press CONTINUE to complete this operation!", _
MyPoint1 _
)
Debug.Print "MyDocID1 = " & Str(MyDocID1)
'Determine which blob the point was within
MyBlobID1 = IpBlbHitTest (MyPoint1.X, MyPoint1.Y)
Debug.Print "MyBlobID1 = " & Str(MyBlobID1)
'Error trap
If ( Not(MyDocID1 > -1 And MyBlobID1 > -1) ) Then
'Jump to the end of the subroutine
GoTo MYENDER
End If
MYENDER:
End Sub
0
Best Answer
-
Yuri --
Thank you for your prompt response and for the example code.
I don't think this addresses the issue though.
If I have an image with 25 objects in RANGE 1 and 25 objects in RANGE 2, then I can have:
** 2 objects with ID 1
** 2 objects with ID 2
.
.
.
** 2 objects with ID 25
If I use
IpBlbHitTest
as shown in SUBROUTINE ZZZ, IPP7 will give me the
DOC ID
and
OBJ ID
for a clicked on object but I do not know which of the two possible objects with the ID has been clicked.
The only way I see to do this is to strip out the RANGE 1 objects into IMAGE 1 and strip out the RANGE 2 objects into IMAGE 2 and then perform the
IpBlbHitTest
within IMAGES 1 and 2 and find out which IMAGE / RANGE returns the
DOC ID
and
OBJ ID
If you can think of a more elegant way to do this, it would be much appreciated.
Thanks.
-- Matt
0
Answers
-
Hi Matt,
There is BLBM_SRANGE measurement that returns object range. You can look at IpBlbGet page of Auto-Pro help that has a sample macro showing how to get range and id of the object.
Here is the sample macro:Sub PrintObjectRanges() Dim iRng As Integer Dim iNumRng As Integer Dim iObj As Integer Dim iNumObj As Integer Dim NextRng As Integer Dim iAllObj As Integer Dim i As Integer, j As Integer 'count the number of segmentation ranges ret = IpBlbGet(GETNUMRANGES, 0, 0, iNumRng) If (ret < 0) Then Exit Sub End If 'Make sure that the Range measurement is 'enabled and get rid of hidden objects ret = IpBlbEnableMeas(BLBM_AREA, 1) ret = IpBlbEnableMeas(BLBM_SRANGE, 1) ret = IpBlbMeasure() ret = IpBlbUpdate(4) 'create arrays to hold all of the data 'from all ranges ret = IpBlbGet(GETNUMOBJEX, 0, BLB_ALLOBJECTS, iAllObj) ReDim Areas(iAllObj) As Single ReDim Ranges(iAllObj) As Single NextRng = 0 'Label the output ret = IpOutputShow(1) ret = IpOutputClear() Debug.Print "Objects by Range" Debug.Print "Rng-Obj"; Debug.Print Chr(9); "Area"; Chr(9); Debug.Print "Range" 'Iterate through the ranges For iRng = 0 To iNumRng - 1 IpBlbRange(iRng) ret = IpBlbGet(GETNUMOBJEX, 0, BLB_ACTIVERANGE, iNumObj) ReDim tmpAreas(iNumObj) As Single ReDim tmpRanges(iNumObj) As Single ret = IpBlbData(BLBM_AREA, 0, iNumObj-1, tmpAreas(0)) ret = IpBlbData(BLBM_SRANGE, 0, iNumObj-1, tmpRanges(0)) 'iterate through the objects in the 'current range and build data lists 'for all objects in the image For iObj = 0 To iNumObj - 1 Debug.Print iObj+1; Debug.Print Chr(9); tmpAreas(iObj); Debug.Print Chr(9); tmpRanges(iObj) Areas(NextRng + iObj) = tmpAreas(iObj) Ranges(NextRng + iObj) = tmpRanges(iObj) Next iObj NextRng = NextRng + iNumObj Next iRng 'label the output Debug.Print "" Debug.Print "The entire list of objects" Debug.Print "Obj #"; Debug.Print Chr(9); "Area"; Debug.Print Chr(9); "Range" 'iterate through all objects in the image For iObj = 0 To iAllObj - 1 Debug.Print iObj+1; Debug.Print Chr(9); Areas(iObj); Debug.Print Chr(9); Ranges(iObj) Next iObj End Sub
Regards,
Yuri0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions