Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use IMAQ Find Horizontal Edge when some images don't have an edge

I am using IMAQ Find Horizontal Edge and IMAQ Find Verticle Edge on images.  I am extracting the area inside the edges and then doing some processing.  If there are no edges, I just want to process the whole image.  Some of the images "do not have an edge", but the vi returns some crazy line coordinates.  How can I figure out if the image actually has an edge or not?

 

More information:  I am using a line scan camera to capture an object moving in front of the camera.  The lines accumulate into a very large image, 2048 x ~30,000 pixels.  The user only sees a moving window of the image, representing the viewable area in front of the camera.

 

I am extracting the viewable area, looking for the edges, extracting the area inside the edges, and then doing some processing on the image. As the image enters the view from the top (see image1.png) there will be an edge on the bottom, but not the top.  as the object moves, there will not be any edge visible on the bottom or the top (image 2.png).  As the image leaves the view, there is an edge on the top of the image (image3.png)

 

So what I need to figure out is how to tell when there are no "good" edges.  In this case, I will do my processing on the whole image.

 

Thank you,

Glen

Download All
0 Kudos
Message 1 of 8
(4,755 Views)

Hi Glen

 

It looks like the line you are trying to detect is very subtle, all the other ink blotches or bright spots in your image may lead to the IMAQ find edges detecting misnomers. You can try setting a very small ROI or edge detection line around/across specifically just where you predict your line to be and setting the sensitivity just low enough so that it can detect the line. If a line is not found within the minimum edge strength then you will get no results. I recommend placing your image in Vision Assistant and playing with the edge strength until you find the right settings.

 

Thank You

Eric Reid


Thank You
Eric Reid
National Instruments
Motion R&D
0 Kudos
Message 2 of 8
(4,717 Views)

Just to clarify... I'm not having any problem detecting the edges - when there are edges present, ie: in image1.png and image3.png, above (I'm looking for top and bottom edges).  The problem is when the product completely fills the view, like in image2.png,  there is no edge on the bottom or the top.  Is there a way for the edge detection vi's to tell me there is not a good edge to be found such as when the product consumes the entire frame?  In such a case, I want to use the top of the frame for the top edge, and the bottom of the frame for the bottom edge.

 

Thanks for your help.

 

Glen

 

 

0 Kudos
Message 3 of 8
(4,703 Views)

Hi Glen

 

If the image fills the entire frame and your minimum score is set high enough you should not find any edges. You can then programmatically set the bounds to do image processing to cover your entire image. You could run an IMAQgetImageSize.VI and have this set the bounds to operate in for instance. Attached below is the Vision Concepts Manual which may also assist in finding more specifics on the edge finding techniques we offer.

 

 Vision Concepts Manual:

http://www.ni.com/pdf/manuals/372916g.pdf

 

Thank You

Eric Reid


Thank You
Eric Reid
National Instruments
Motion R&D
0 Kudos
Message 4 of 8
(4,679 Views)

Glen,

 

I would use horizontal average to get the average brightness.  There will be one distinct edge, and all the defects will be averaged out.  Look at the min and max values to decide if there is an edge or not.  For example, if the range is about 10, there is not an edge.  If the range is 100, there is a significant edge.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 5 of 8
(4,670 Views)

Bruce.  That's a good idea.  I will start from the top of the image, add the intensity of all the pixels in a row, then divide by the width for the average value. You mentioned horizontal average, maybe there is a VI for that, I'll look.   As you said, when the average exceeds some threshold, I have found the top edge.  The beauty of this is that if the frame is filled with the product image, the first line will exceed the threshold, and line 0 will be the top edge, just what I want.

 

I will do the same thing from the bottom to find the bottom edge.

 

Thanks Bruce!

0 Kudos
Message 6 of 8
(4,667 Views)

There is a VI that does it for you.  I don't remember the exact name, but it does horizontal, vertical, and diagonal averages.  I have never found a use for the diagonal averages, but the horizontal and vertical have come in handy many times.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 7 of 8
(4,660 Views)
For others who may read this post, the vi is called "IMAQ LinearAverages".  It is in the Vision and Motion / Image Processing / Analysis function pallette.
0 Kudos
Message 8 of 8
(4,643 Views)