Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edge detection in C#

I'm trying to think of a efficient way to trace the outlines of homogeneously colored regions of a bitmap image and save them as GraphicsPath objects.

Check out this small sample image:

enter image description here

Now, most edge detection type of stuff I can find are either way too complicated - working on photos with varying degrees of brightness and so on - my edges are very easy to detect, simple any minute change in the RGB values means its an edge.

But also I have a more involved situation than the simplest things that scan a whole image for one blob to edge detect on. I have regions which share boundaries and I need to be as efficient as possible because speed is a bigtime issue.

Can anyone give me some pointers on how to accomplish this? Pseudo code or real code would be awesome

Ideally I can scan line by line building up the outlines of each distinct region simultaneously. But this kind of coding is beyond my skills since I am crappy at math.

like image 384
Trant Avatar asked Feb 24 '26 16:02

Trant


1 Answers

I would try:

  • Connected component labeling followed by
  • Marching squares to trace the edges of the components.

It is probably doable to find standard libraries that do the above, and do so efficiently and correctly. After you have this working you can think about optimizations like avoiding detecting an edge twice.

If you need this optimization, my guess is that will have to write this yourself. If you can't, make sure someone is hired who can.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!