# How to find the distance of a point from center in matlab

#### Siv77

Joined Jul 17, 2021
13
I need to find the position of sun from the center of the image in matlab.
Also how to draw vertical and horizontal lines from the center point in matlab

#### Papabravo

Joined Feb 24, 2006
19,319
If this is a 2-D image and the center of the image is assigned the coordinates (0,0) then the position p, is given by (x,y) where x and y are the distances along a pair of orthogonal axes. The distance of the point p(x,y) from the origin at (0,0) is:

$$p(x,y)\;=\;\sqrt{x^2\;+\;y^2}$$

Drawing horizontal and vertical lines can be done in several different ways:

plot - How to draw horizontal and vertical lines in MATLAB? - Stack Overflow

#### Siv77

Joined Jul 17, 2021
13
Here the x axis is not throught the center of image. Why is that so?

#### Papabravo

Joined Feb 24, 2006
19,319
How would you define the center of the image? I would define it in terms of the number of pixels in each dimension. There may or may not be a pixel in the center of the image. In order for that to be the case the number of pixels in each direction would need to be odd and AFAIK that never happens in image processing.