Jump to content
ASalcedo

How to get minimun distance between first and last edges

Recommended Posts

Hello to all.

I have an image and a ROI.

I would like to get the minimun distance between the first edge and the last edge in horizontal position.

See image attached. If every edges found are in color yellow I would like to get the distance between edges in red (minimun distance from last edge to last edge in horizontal direction.

I have tried to use "IMAQ Clamp Horizontal Min VI" but this VI does't the option "from first to last edge" and the only way to get what I want is to play with contrast but it is not work for some of my images.

So is there any way to get what I want?

Here is the image.

Selección_055.png

From fist edge to last edge I mean from left to righ, the first edge found and last edge found.

Thanks a lot.

 

Share this post


Link to post
Share on other sites

I don't have IMAQ installed, but I used a similar technique for detecting the edges of LCD segments.  First get consistent lighting and positioning.  Good, consistent, and uniform lighting is an art form.  Once you have that turn the image into a binary one.  You'll want some kind of thresholding applied and maybe a routine that allows you to adjust the levels.  Alternatively you could try to auto detect the binary levels needed using the histogram data.  From there I'd use pure math and abandon any premade NI functions.  Partially because I'm not familiar with all of them, but also because if they fail to work properly I can't debug them and figure out why.  In this case the math probably should be too hard.  Your image is now just black or white pixels and you can apply a small filter to maybe eliminate any noise (like remove any black pixels not surrounded by black pixels).  Then I'd split the image in half and process each half looking for the black pixels that are the farthest right, and farthest left.  Then row by row look to see which points are the closest, and calculate the number of pixels between them.

Share this post


Link to post
Share on other sites
On 9/2/2017 at 2:37 PM, hooovahh said:

I don't have IMAQ installed, but I used a similar technique for detecting the edges of LCD segments.  First get consistent lighting and positioning.  Good, consistent, and uniform lighting is an art form.  Once you have that turn the image into a binary one.  You'll want some kind of thresholding applied and maybe a routine that allows you to adjust the levels.  Alternatively you could try to auto detect the binary levels needed using the histogram data.  From there I'd use pure math and abandon any premade NI functions.  Partially because I'm not familiar with all of them, but also because if they fail to work properly I can't debug them and figure out why.  In this case the math probably should be too hard.  Your image is now just black or white pixels and you can apply a small filter to maybe eliminate any noise (like remove any black pixels not surrounded by black pixels).  Then I'd split the image in half and process each half looking for the black pixels that are the farthest right, and farthest left.  Then row by row look to see which points are the closest, and calculate the number of pixels between them.

Thanks a lot for answering.

I have just done it with imaq pallete. It is easy to do it.

thanks a lot.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.