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
-
It works correctly in my tests. You should get something like this:Sub IrregularAOI()ret = IpListPts(Pts(0), "157 86 47 219 181 379 158 222 312 292 275 108 277 108 277 107 278 107 ")ret = IpAoiCreateIrregular(Pts(0), 9)End Sub
Tested in IPPlus 7.0.1
Yuri
0 -
What are the points it is listing? Are they pixels or intensity values? And are you making up the points or is it finding them?0
-
These are X and Y coordinates of the polygon, they are recorded as you click image drawing AOI.0
-
Okay, so you got those points by recording and doing it manually? Maybe I didn't get those because I used the wand tool to create my polygon?0
-
Maybe, just try drawing the polygon, so you get recorded coordinates.0
-
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?
0 -
Great and once I convert the initial count outline to an AOI can I then count the objects inside of the AOI to classify them? Sorry if I am being difficult! And I know Premier would be better for what I am trying to do except I need the automated image capture with StagePro and Premier does not have that capability yet. So I am trying to do see how much I can do with macros in IPP.0
-
Yes, the new Count will be executed within AOIs only.0
-
Perfect. Thank you so much for your help!0
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