From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Find the number of edges in an image

Solved!
Go to solution

HI,

I'm working on a project in which I need to detect the number of edges in each of the particle present in the image.

Can anyone please help me out with it.

My progress till now is that I've been able to detect all the edges of the particles in the image successfully using Canny edge. However I'm not able to count the number of edges in individual particle.

Thanks

Regards

Aveo

0 Kudos
Message 1 of 7
(5,267 Views)

Hello aveo,

 

could you please clarify the problem a bit because I think I don't understand what do you mean by number of edges.

 

The number of edges could be 1, 2 10 or 1000, etc... Depends on how many pixels you segment the edges. What is an "edge" in your case? A closed contour?

 

This statement is not clear to me "However I'm not able to count the number of edges in individual particle". One particle has one edge.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 2 of 7
(5,264 Views)

Hi K,

I'm attaching an image titled "particle.png". In the image you can see that there are two particles. Now when i apply Canny edge on the image, i get several edges for each particle.

I want to count how many edges are there in each of the TWO particle present in the image.

 Regards

Aveo

0 Kudos
Message 3 of 7
(5,253 Views)

I've extracted the 1st particle(the bigger particle) from the image "particle.png" and applied Canny Edge to it and the output that i got is 'particle 1.png'.

now you can see that there are so many edges coming up.

What i want is to find out is the number of white lines(which in this case are the edges) that are present in the image "particle 1.png".

Hope i clarified the problem.

 

Regards

Aveo 

Download All
0 Kudos
Message 4 of 7
(5,250 Views)
Solution
Accepted by topic author aveo

Hello aveo,

 

how about performing particle measurements after Canny (please see the attached code). Use connectivity 8, which searches for all adjecent pixels if they are a part of the same line segment (see the image below):

 

connectivity.png

 

Ni Vision Concepts manual:

"With connectivity-4, two pixels are considered part of the same particle if they are horizontally or vertically adjacent. With connectivity-8, two pixels are considered part of the same particle if they are horizontally, vertically, or diagonally adjacent. The following figure illustrates the two types of connectivity."

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 5 of 7
(5,226 Views)

Hi Klemen,

Thanks for the wonderful and simple solution to the problem. You made my task a lot easier now.

Thanks a lot.

Regards

Aveo

0 Kudos
Message 6 of 7
(5,194 Views)

No problem.

 

Glad it helped you out! Smiley Happy

 

Good luck with your project.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 7 of 7
(5,192 Views)