Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

imaqMorphology and image borders

the documention for the function imaqMorphology() states about the source image:
"The calculation modifies the border of the source image. The border must be at least half as large as the larger dimension of the structuring element."
(quoted from "NIVIsion for LabWindows/CVI Function Reference Help", July 2007, 370379F-01 )

this is not really clear: should we set the border ourselves, or does the function take care of that ? if we set the border, why does the function needs to modify it ? if the function modifies the border, why do we need to set it ?

any time i call this function, passing it a borderless image as the source image, the function breaks, giving this error:
NON-FATAL RUN-TIME ERROR:   "processing.c", line 539, col 5, thread id 0x000005E4:   Function imaqMorphology: (errorCode == -1074396072 [0xbff60458]). Invalid image border.
i think the function does not modify the border, but i'm not quite sure...
0 Kudos
Message 1 of 8
(6,218 Views)
Hi,
 
Logically, if you get an error "Invalid Image Border" it means that size of the border is not large enough. You have to set border 1 for structuring element 3x3, 2 for 5x5 and so on. You must set border before call or create image with border initially, because this function will not modify the size of the border, and you can't pass borderless image as input. In additional, this function will modify the source image (this also documeted behaviour). So, here help means (I guess), that the pixels in the border will be modified (but not the size).
Theoretically you can visualize border of the image after calling imaqMorphology() and see what changed exactly.
 
Hope it helps.
 
best regards,
Andrey.
 
0 Kudos
Message 2 of 8
(6,206 Views)

Andrey - based on your reply above, I wanted to revisit a similar topic this and get your thoughts.

 

I am implementing a median filter using IMAQ NthOrder VI.  When the element size of the kernel is greater than 7 x 7, I get the same error "Invalid Image Border."

 

I tried to adjust this based on your strategy mentioned regarding setting a new border size.  I still get the error.  Any thoughts on this?

 

medianfilter.PNG

 

Thanks,

 

Don

 

0 Kudos
Message 3 of 8
(5,743 Views)

Hi Don,

 

You need to set the correct border when you create the images with the "IMAQ Create" VI.  The border input is on the top of the VI.  The default is 3, which is why a 7x7 kernel works.

 

Please see http://zone.ni.com/reference/en-XX/help/370281L-01/imaqvision/imaq_create/ for more information.

 

-Jeff

Message 4 of 8
(5,727 Views)

Hi, Don,

 

The size of the border of SOURCE image is important. You can set up border with IMAQ Create (this way is prederred), or you can change border after creation (in this case image will be relocated). Border of destination image is not important.

 

Andrey.

 

Message 5 of 8
(5,719 Views)

Still no luck with 9 x 9 after modifying the code to create the border of the source image.  I must be doing something wrong.  Here is what the main portion of the code looks like and the VI is attached.

 

medianfilter.PNG

 

 

Any help is appreciated!

 

Thanks,

 

Don

0 Kudos
Message 6 of 8
(5,694 Views)

Don,

 

Check the border size of the image coming out of IMAQ Copy.  I will bet it is the same size as the original image, because I think the border of the source image is copied along with the rest of the image.  You need to set the image border after you copy it, or change the border of the original image.

 

Bruce

Bruce Ammons
Ammons Engineering
Message 7 of 8
(5,691 Views)

Bruce - Thanks.  That was the final piece of the puzzle.  Now it works for all kernel sizes.....Don

 

medianfilter.PNG

0 Kudos
Message 8 of 8
(5,680 Views)