Home Image-Pro Plus Automation with Macros

Apply a morpho closing to an image instance

(Originally posted by August on 2/2/2007)

Greetings to all.
I work with HAIL functions. I have difficulty in execution of function FltClosing. What means the third parameter in this function In a HALO programmin guide it is specified so:

Syntax: IMERROR FltClosing(iiInst, Shapes, Count, lpTrack)

Description: Applies a morphological closing filter (a dilation followed by an erosion) to an image instance.

iiInst IMINST Image instance handle.
Shapes LPMORPHO Points to an array of morphological filter shapes.
Count WORD Number of shapes in the array.
lpTrack LPTRACK Pointer to Status Tracking Structure.

Return Value: The return value is an IMERROR code. See IMERROR under HAIL Error Codes.

Comments: The morphological filter shapes are applied one after the other in the order that they appear in the Shapes array.

But if to execute on the image function (iiInst, MORPHO_1x3COLUMN, 7, lpTrack) and high-order function IpFltClose(MORPHO_1x3COLUMN, 7) that results will differ.



  • (Originally posted by YuriG on 2/2/2007)

    The second parameter in FltClosing is a pointer to an array of morpho shapes (so you implementation is not correct) and the third is the number of shapes in the array, while IpFltClose takes one shape defined in first parameter and the passes are defined in the second parameter.

  • (Originally posted by August on 2/2/2007)

    ReDim MorphShapeArr(6)
    For i = 0 To 6
    MorphShapeArr(i) = MORPHO_1x3COLUMN
    ret = FltClosing(iiInst, MorphShapeArr(0), 7, lpTrack)

    Why at value of number of shapes in the array more than three stand out a mistake? (ret = -985)


  • (Originally posted by YuriG on 2/2/2007)

    You have to specify the correct type when you create MorphShapeArr, it should be integer (if type is not specified the array is allocated as VARIANT).
    I see that you are using VB, in that case you can just use IpFltClose.

  • (Originally posted by August on 2/2/2007)

    I use VB.Net in the environment of development Visual Studio 2005. I define a MorphShapeArr as type SHORT. But how I can use IPFltClose if I work with the virtual image and its instance?

  • edited June 2013

    (Originally posted by YuriG on 2/2/2007)

    I checked the code. The array must be long integer. The following test macro works correctly in IPBasic:

    Declare Function FltClosing Lib "HALFLT32" (ByVal hVriInst As Long, ByRef Shapes As Long, ByVal count As Integer, lpTrack As Long) As Long
    Declare Function HilImOpen Lib "HILIMG32" (ByVal ihImage As Long, ByVal iaAccess As Long, lpRect As RECT) As Long
    Declare Function HilImClose Lib "HILIMG32" (ByVal iiInst As Long) As Long
    Sub TestFlt()
    	Dim i%
    	ReDim MorphShapeArr(6) As Long
    	For i = 0 To 6
    		MorphShapeArr(i) =MORPHO_1x3COLUMN
    	Dim iiInst As Long, r As RECT
    	Debug.Print "iiInst " & iiInst
    	ret = FltClosing(iiInst, MorphShapeArr(0), 7, IPNULL)
    	Debug.Print ret
    End Sub

    Since you are using .NET you should specify ByRef in the function definition for Shapes (in VB6 it was by default, in .NET the default is ByVal).

Sign In or Register to comment.