Edge Finding

I have an image (see attached) which consists of edges. I need to associate edge pixels into individual edges. Each pixel belonging to only one edge. The ultimate goal is to measure the length of an edge and compare to the straight line distance from the starting to ending pixels in that edge. Edges are generally well separated; that is edges are generally further apart than adjacent pixels within an edge.

I am working on a procedure that identifies the nearest neighbor (within some permitted level of separation) to a given pixel and thus jumps from pixel to pixel to define a connected edge. This seems to be a brute force method; can anyone suggest a more elegant and simpler method?

Thanks,

Jeff

Hello Jeff,

It is difficult to tell from the image you posted if the various "edges" are fully connected. If they are you can convert the image (if it is not already) to a binary representation where your "edges" are set to zero and the background to 255 and use ImageAnalyzeParticles. This will give you each "edge" as a particle including a starting pixel. You could also use the second moments to compute the fitting ellipse which would give you a general direction of the "edge".

If the lines are not strictly connected but have very small gaps I'd consider using ImageMorphology to close the gaps prior to running particle analysis.

Finally, note that if you just want to follow connected domains you can use ImageSeedFill. Here you can play a trick by extending the data to 3D (setting say 3 layers to the same values) and then using some of the adaptive options of the seed-fill algorithm to also close the gaps. I mention this only because it is possible but I think the methods I mentioned above are more straightforward.

If you want me to look into it in more detail, feel free to send me directly an experiment with an image.

A.G.
WaveMetrics, Inc.
AG,

Thanks for the suggestions. Unfortunately, I don't think the edges are fully connected. See the attached images, which show expanded regions of the image included with my original post. Graph8a shows what should be a single edge with gaps between some of the pixels. Graph8b shows a detail with parts of two edges, each edge has a different colored line drawn along side it to show which pixels belong to which edge. The red profile has significant gaps, while it would be nice to bridge as many of these gaps as possible, I think, at this point in the process, at least, that trying to bridge too large of a gap may introduce other problems and complexities.

I will follow up with your ideas and will send post an experiment containing the data file.

Thanks,

Jeff
Graph8a.png (9.46 KB) Graph8b.png (12.06 KB)