Home Image-Pro Plus Automation with Macros
Options

How to obtain pointapi array for hole within AOI

(Originally posted by JohnP on 7/3/2006)


I can use this command to obtain the POINTAPI array for a white object #i on a black background found with the Count Command.

ReDim blbpts(numpoints) As pointapi

numpoints = IpBlbGet(GETPOINTS, i, 1000, pts(0))

---

I'm next interested if I can obtain the POINTAPI array for a black hole within this object. Is there an easy way to do this?

Comments

  • Options
    edited June 2013

    (Originally posted by Chris Tully on 7/5/2006)

    One approach is a two step count. In step one you count for bight objects as you are doing, and use:

    Dim numpoints as integer
    Dim blbpts() as POINTAPI
    
    ret = IpBlbGet(GETNUMPTS, i, 0, numpoints)
    redim blbpts(numpoints) as POINTAPI
    ret = IpBlbGet(GETPOINTS, i, numpoints, blbpts(0))
    



    to get the outline of the object with a hole. Then use:

    ret = IpAoiCreateIrregular(blbpts(0), numpoints-2)



    to create an AOI of the same size and shape as the object. Then count for Dark objects and use the code above to get the Hole's outline.

    A couple of points to make about my code snippets:
    1) I explicitly get the number of points and resize the blbpts array accordingly before getting the points with GETPOINTS, this insures that the array is always exactly the right size, and avoids the possible problem of only getting the first 1000 points that your code may have.
    2) In the call to IpAoiCreateIrregular, I use numpoints-2 to account for the way IPBASIC creates arrays, and a difference in the way IpBlbGet(GETPOINTS, ..) and IpAoiCreateIrregular() deal with point lists. IPBASIC (like VB) handles the statement:
    ReDim Array(number) as Type
    by creating an array with valid indexes from 0 to number (this means that you actually have number + 1 valid index in the array). So, you would typically use number - 1 as the number of elements in the array, because all of the IpXxxx functions are actually writting in C/C++ where arrays are indexed from 0 to number - 1 (not number!).

    However, because of the the way Count/Size handles object outlines, the last point is identical to the first point, but IpAoiCreateIrregular does not like the duplication of the first point, so you subtract one more point from the list that you tell IpAoiCreateIrregular to use.

Sign In or Register to comment.