Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Cause of "Invalid Image Border" error in GrayMorphology call

In an attempt to perform a Dilation operation using the GrayMorphology() method, I get an error 31088 'Invalid Image Border'. This happens when I try to initialize the CWIMAQStructuringElement argument to a width and height greater than 5 (odd sizes only). Only sizes of 3 or 5 seem to work. My images are 8-bit with size of 750x750.

The subroutine I am using is below:

Private Sub Dilate()
Dim i As Long
Dim dilateSize As Long
Dim morphStructure As CWIMAQStructuringElement
'
' Initialize structuring element according to dilation width
On Error GoTo Dilate_Error
Set morphStructure = New CWIMAQStructuringElement
dilateSize = (spnDilationWidth.Value * 2) + 1
morphStructure.SetSize dilateSize, dilateSize
'Use dilate
CWIMAQVision1.GrayMorphology CWIMAQViewer1.Image, CWIMAQViewer1.Image, cwimaqGrayMorphDilate, morphStructure
Exit Sub
Dilate_Error:
Exit Sub
End Sub
0 Kudos
Message 1 of 2
(6,339 Views)
In Response To: "In an attempt to perform a Dilation operation using the GrayMorphology() method, I get an error 31088 'Invalid Image Border'. This happens when I try to initialize the CWIMAQStructuringElement argument to a width and height greater than 5 (odd sizes only). Only sizes of 3 or 5 seem to work. My images are 8-bit with size of 750x750."

Hey mpu,

The morphology functions require some blank space at the edges of the image, which is considered a border. You can set the size of the border, and you can adjust the size of the border using IMAQ ImageBorderSize. Try calling the imaqSetBorderSize(srcImage,3); function before you initialize the CWIMAQStructuringElement. What might be happening is you might be setting a boarder size that would cause the images to not fit in the area that is allotted for them. The sizes 3 or 5 probably work because they are still within the limits of the border with the image. Is there a reason that you need a larger border size?

Check out the following Discusstion Forums where others have run into this same error:
- "Invalid image border" when running imaqConvolve() despite correct borders...
- I get error 1074396072: imaq morphlogy invalid image border

I hope this helps. Please let me know if you have any other questions. Thanks and have a great day.

Regards,
DJ
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(6,329 Views)