Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find normals to an edge in an image

I am doing some work related to eye images. I did edge detection to it. The edge is like a curve and not continuous. I have to assume it to be continuous and find normals to that curve. How do I find the normals to it using MATLAB?

you can see the image below.

Edge image

I want to find the normals to the upper curve. I hope that I was clear enough.

like image 674
srinath Avatar asked Oct 20 '25 04:10

srinath


2 Answers

Even though it seems unintuitive, the edge direction at every pixel is a pretty good estimate of the normal. This would be the simplest solution, because it doesn't involve any curve fitting.

In MATLAB, you can find pixel-wise edge directions using the Sobel filter:

[BW,thresh,gv,gh] = edge(I,'sobel');
edgeDir = atan2(gv, gh);

This gives you the edge directions as angles in radians.

like image 128
Zaphod Avatar answered Oct 23 '25 06:10

Zaphod


You may want to consider curve fitting (MSE based or some other criteria) to the data. I believe a second order will do good for the upper curve, and once you have a model you can can calculate the tangent and normal at each point.

like image 44
BioSP Avatar answered Oct 23 '25 06:10

BioSP