Finds the index of the feature under a given point.
Dear sir,
I used 'ret = IpBlbHitTest(x,y)' to get object Index on Image Pro Plus 7.
How to get the feature name or index with give xy point on IP10?
We need to hide object when it's on the corner.
i try to ues 'FeatureFromPoint' and 'PointClosestToPoint'. They always return -1.
I used 'ret = IpBlbHitTest(x,y)' to get object Index on Image Pro Plus 7.
How to get the feature name or index with give xy point on IP10?
We need to hide object when it's on the corner.
i try to ues 'FeatureFromPoint' and 'PointClosestToPoint'. They always return -1.
0
Best Answer
-
WesanSyu,
The FeatureFromPoint is for low level functions. If you use Count/Size then you should use higher level functions, below is the macro that hides corner objects:Public Sub GetBoundingBoxes() Dim im As McImage=ThisApplication.ActiveImage If im Is Nothing Then Exit Sub Dim md As McMMData=im.MeasurementsData If md.Count=0 Then Exit Sub Dim rgns As MediaCy.IQL.Features.McRegions=md(0).MainSubFeature.GetFeatures() If rgns Is Nothing Then Exit Sub'it's not regions 'ger ROI box Dim r As Mediacy.IQL.ObjectManager.SINGLERECT=im.Aoi.BoundingRect Dim bl As Single,br As Single, bt As Single,bb As Single Dim sides As Integer=0 For Each sf As McMMSubFeature In md.SubFeatures sides=0 sf.GetBoundingBox(bl,bt,br,bb)'get object bounding box 'print array of values 'Debug.Print(String.Format("{0} - [{1},{2},{3},{4}]", sf.Name,bl,bt,br,bb)) If r.top=bt Then sides+=1 If r.bottom=bb Then sides+=1 If r.left=bl Then sides+=1 If r.right=br Then sides+=1 If sides=2 Then 'corner object Debug.Print(String.Format("{0} - [{1},{2},{3},{4}]", sf.Name,bl,bt,br,bb)) 'hide it sf.Show=False End If Next End Sub
I've also attached the macro project.
The result will look like this:
Yuri0
Answers
Dim MyPoint1 As POINTAPI
Dim MyDocID1 As Integer
Dim MyBlobID1 As Long
'Ask the user to select an object on the original image
MyDocID1 = IpDocClick("Please . . . " & vbCr & vbCr & "CLICK on a point within the AXON CLUSTER you want to split!", 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
'Make a mask of the original objects and remember its id
Dim ID_MaskA As Integer
ID_MaskA = IpBlbCreateMask()
'Change the name for the mask image
ret = IpWsChangeDescription(INF_NAME, "MaskA")
'Activate the original image
ret = IpAppSelectDoc(ID_Original)
'Get the boundary points for the object selected by the user
Dim numpoints As Integer
ReDim blbpts(1000) As POINTAPI
numpoints = IpBlbGet(GETPOINTS, MyBlobID1, 1000, blbpts(0))
'Delete all existing objects
ret = IpBlbDelete()
'Create AOI out of the selected object's outline
ret = IpAoiCreateIrregular(blbpts(0), numpoints)
'Change the aoi into a new object that is the same as the selected object
ret = IpBlbFromAoi(1)
If you want to hide a measurement object in Image-Pro 10, the easiest way would be to select this object (using an interactive macro command) and then delete or hide it.(the commands are recordable).
Yuri
I know how to select one or more object by using macro command.
The following is my measure step:
1. Get any picture with particles.
2. Add a fixed size ROI to the image.
3. Set measurement conditions. Then counting object.
4. The corner object index is not the same in every pictures. So I have to get the feature index of these particles which is in the corner.
I don't want to select object with mouse click. I want to select and hide certain objects automatically.
That I known ROI's corner point. Maybe I can use the 'FeatureFromPoint' command to get measurement feature Index.
Currently, I want to know How to use 'FeatureFromPoint' command?