Macro for creating irregular AOI in Image-Pro Plus
Hi,
I am trying to have a macro in IPP that identifies the outline of an irregular object across an image and make it an irregular AOI. Then be able to count the objects inside of that AOI and classify them based on area. When I recorded a macro and identified the irregular AOI it gave me the below code. However, when it runs on its own it fails to identify the AOI and therefore the counts the wrong objects.
'<c>H
ret = IpWsLoad("F:file.tif","tif")
ret = IpAoiMultShow(1)
ret = IpAoiMultAppend(1)
ret = IpBlbShow(1)
ret = IpBlbCount()
ret = IpBlbShowSingleClass(0, ipBins(0), 2, 1)
ipBins(0) = .2866733
ipBins(1) = 26.0
ipBins(2) = 1070.983
ret = IpBlbShowSingleClass(0, ipBins(0), 2, 1)
ret = IpBlbCreateMask()
End Sub
When I looked it up in the manual it states to use the below code but I don't quite understand what the points are that they mention? Are they pixels or intensity values?
ret = IpListPts
ret = IpAoiCreateIrregular (Pts (0), 7)
Thanks,
Jena
Best Answer
-
You are asking about converting Count outlines (which you can create based on threshold segmentation) to AOIs.
I've found an old macro that does this:Sub Count_To_Aoi()Dim numpoints As IntegerDim numobj As IntegerDim i As Integer, status As Integer' number of objectsret = IpBlbGet(GETNUMOBJ, 0, 0, numobj)If numobj < 1 Thenret = IpMacroStop("Please count objects first", MS_MODAL)GoTo end_aoi_objectsEnd If' reset the multiple Aoiret = IpAoiMultShow(1)ret = IpAoiMultAppend(0)For i = 0 To numobj - 1' is object in range?ret = IpBlbGet(GETSTATUS, i, 0, status)If status >= 0 Then' get the object's outlinenumpoints = IpBlbGet(GETPOINTS, i, 1000, Pts(0))If numpoints > 0 Then' create an AOI from the outlineret = IpAoiCreateIrregular(Pts(0), numpoints)ret = IpAoiMultAppend(1)End IfEnd IfNext iend_aoi_objects:End Sub
You just have to create some segmented objects (using Count) and then run this macro.
BTW, in the current version of Image-Pro, Image-Pro Premier this can be done easily using Features Manager (conversion between AOIs, Measurement outlines, Annotations,...).
Yuri
0
Answers
Tested in IPPlus 7.0.1
Yuri
Yes that worked! Thanks!
I have another question though and I am hoping this is possible? I will have multiple images where the object that I want to be the area of interest may be in different places. Since I had to do this manually to record and find the points (and these points may not be the same for every image analyzed), is there anyway for it to go through the image and find the points automatically? Or maybe find points based on grayscale value?