# Finding blob centers with keypoints or centroids?

**URL:** <https://forum.opencv.org/t/finding-blob-centers-with-keypoints-or-centroids/4757>\
**Category:** C++\
**Created:** [August 13, 2021, 11:52pm UTC](https://forum.opencv.org/t/finding-blob-centers-with-keypoints-or-centroids/4757 "2021-08-13T23:52:25Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![rg0001](https://avatars.discourse-cdn.com/v4/letter/r/9dc877/32.png) [@rg0001](https://forum.opencv.org/u/rg0001)\
**Post date:** [August 14, 2021, 5:22pm UTC](https://forum.opencv.org/t/finding-blob-centers-with-keypoints-or-centroids/4757/3 "2021-08-14T17:22:05Z")

</div>

Hi thanks for the recommended solution. Would a “geometric solution” be acceptable as well as simpler? I basically find the leftmost, rightmost, lower-most, higher-most pixel coordinates of the blob in the image plane and calculate the rectangular center from this virtual bounding box. Assuming a relatively symmetrical blob which I am using. How can I find the coordinates marked with “?”  
Pseudo:

```auto
Main
{
…
// per found blob
double Pixel_leftmost = ?
double Pixel_rightmost = ?
double Pixel_upmost = ?
double Pixel downmost = ?

double Width_blob = Pixel_rightmost - Pixel_leftmost
double Height_blob = Pixel_downmost - Pixel_upmost // avoid neg quant

double Ctr_x = Width_blob/2
double Ctr_y = Height_blob/2
…
}

```

---

_[View the full topic](https://forum.opencv.org/t/finding-blob-centers-with-keypoints-or-centroids/4757)._
