# Calculate normal 2d vectors of a edge line and its vector angle with respective to y axis

21 visualizzazioni (ultimi 30 giorni)
hyz il 27 Apr 2017
Commentato: DGM il 25 Lug 2022
I am working on extracting features from detected edge as shown in the attached image. I have data set of edge coordinate (x,y). My goal is to determine the normal vector of this edge line and compute the angle with respect to y-axis. So the found angle can be used to rotate the tilted image.
1. Extract edge coordinate (x,y) 2. Determine normal vectors using edge coordinates 3. Compute angle between normal vector and y-axis 4. Rotate the image by angle found at 3.
Any helps or suggestions would be highly appreciated.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Fei Deng il 1 Mag 2017
Hello, since you have data set of edge coordinate (x,y), you can:
(1) get the angle between this edge line and x-axis by doing linear fit.
Now you have the information of normal vector at well. The angle between normal vector and y-axis is same as angle between this edge line and x-axis.
(2) To rotate the image by θ, you can rotate every point (vector) by θ, then trigonometry states that the new coordinates (x', y') are
x' = x cos θ − y sin θ
y' = x sin θ + y cos θ
If you do not have data set of edge coordinate (x,y) at the very beginning, and you want to extract them from an image file, assuming that you have computer vision system toolbox, you can try detecting corners. Take a look at this page https://www.mathworks.com/help/vision/object-detectors.html, unfold "detect objects using point features".
##### 2 CommentiMostra NessunoNascondi Nessuno
hyz il 1 Mag 2017
Hi Fei Deng. Thank you for your feedback.
(1) I am using ctool function to get linear fit line.
Could you point me any direction on computing angles between 2 lines on MATLAB? And how we would know the normal vectors information? Could you elaborate that further?
(2) could i use imrotate as well to achieve the same thing you mentioned?
DGM il 25 Lug 2022
how to find normal vector in each edge pixel?

Accedi per commentare.

### Categorie

Scopri di più su Watermarking in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by