# Bounding box location from the center of the image

**URL:** https://community.ultralytics.com/t/bounding-box-location-from-the-center-of-the-image/493
**Category:** YOLO
**Tags:** yolo
**Created:** [November 10, 2024, 7:30am UTC](https://community.ultralytics.com/t/bounding-box-location-from-the-center-of-the-image/493 "2024-11-10T07:30:12Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Or\_Perez](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/or_perez/32/259_2.png) [@Or\_Perez](https://community.ultralytics.com/u/Or_Perez)
#### Post date: [November 10, 2024, 7:30am UTC](https://community.ultralytics.com/t/bounding-box-location-from-the-center-of-the-image/493/1 "2024-11-10T07:30:12Z")

</div>

Hello everyone.  
I need to retrieve the location of the bounding box relative to the center of the image.  
for that, I use `results.boxes[0].xywh` but I’m not sure where x and y are measured from.  
are they measured from the top-left of the image or from the center of the image?

couldn’t find it in the docs. tnx! 🙂

---

<div class="post-metadata">

### Author: ![pderrenger](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/pderrenger/32/73_2.png) [@pderrenger](https://community.ultralytics.com/u/pderrenger)
#### Post date: [November 10, 2024, 8:28am UTC](https://community.ultralytics.com/t/bounding-box-location-from-the-center-of-the-image/493/2 "2024-11-10T08:28:10Z")

</div>

Hello! 😊

Great question! The `results.boxes[0].xywh` method returns bounding box coordinates in the format `[x_center, y_center, width, height]`. Here, `x_center` and `y_center` represent the center of the bounding box, and these values are measured from the top-left corner of the image, not the center.

If you want to calculate the position relative to the center of the image, you can do so by subtracting half of the image’s width from `x_center` and half of the image’s height from `y_center`. Here’s a quick example:

```python
image_center_x = image_width / 2
image_center_y = image_height / 2

relative_x = x_center - image_center_x
relative_y = y_center - image_center_y

```

This will give you the coordinates of the bounding box center relative to the image center. For more details on handling bounding boxes, you might find the [Ultralytics documentation](https://docs.ultralytics.com/reference/engine/results/) helpful.

Feel free to ask if you have more questions! 🌟

---

<div class="post-metadata">

### Author: ![Toxite](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/toxite/32/123_2.png) [@Toxite](https://community.ultralytics.com/u/Toxite)
#### Post date: [November 10, 2024, 8:55am UTC](https://community.ultralytics.com/t/bounding-box-location-from-the-center-of-the-image/493/3 "2024-11-10T08:55:15Z")

</div>

For images coordinates in general, the convention is to have origin at the top-left.

---

<div class="post-metadata">

### Author: ![Or\_Perez](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/or_perez/32/259_2.png) [@Or\_Perez](https://community.ultralytics.com/u/Or_Perez)
#### Post date: [November 11, 2024, 6:08am UTC](https://community.ultralytics.com/t/bounding-box-location-from-the-center-of-the-image/493/4 "2024-11-11T06:08:33Z")

</div>

Thank you!

---

<div class="post-metadata">

### Author: ![Or\_Perez](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/or_perez/32/259_2.png) [@Or\_Perez](https://community.ultralytics.com/u/Or_Perez)
#### Post date: [November 11, 2024, 6:09am UTC](https://community.ultralytics.com/t/bounding-box-location-from-the-center-of-the-image/493/5 "2024-11-11T06:09:25Z")

</div>

Thank You!
