# Plot Profile function

**URL:** https://forums.openmv.io/t/plot-profile-function/1360
**Category:** OpenMV Boards
**Created:** [July 22, 2019, 11:22pm UTC](https://forums.openmv.io/t/plot-profile-function/1360 "2019-07-22T23:22:17Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![redcrow](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@redcrow](https://forums.openmv.io/u/redcrow)
#### Post date: [July 22, 2019, 11:22pm UTC](https://forums.openmv.io/t/plot-profile-function/1360/1 "2019-07-22T23:22:17Z")

</div>

Is there something similar to the Plot Profile function of ImageJ (with a rectangle) [tudor.lu](https://imagejdocu.tudor.lu/doku.php?id=gui:analyze:plot_profile)? Not looking to plot a chart but interested in the data. Currently looking at a blob that has been binarized and trying to characterize each blob. I do not want the total count of black pixels but to subdivide and get counts for each subdivision. Any help or ideas would be appreciated.

---

<div class="post-metadata">

### Author: ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)
#### Post date: [July 23, 2019, 4:43am UTC](https://forums.openmv.io/t/plot-profile-function/1360/2 "2019-07-23T04:43:39Z")

</div>

Um, there’s a x and y histogram method that will give you the projection of the blob in 1d each direction. This may be what you want.

I.e, the x histogram will return the count of pixels of every column in the blob binned into X number of bins. X will initially be the size of the width of the blob, but, you can make it smaller.

The y histogram will be for the rows of the blob.

If you just want a slice of the blob set the ROI of the blob to just that slice for find\_blobs().

---

<div class="post-metadata">

### Author: ![redcrow](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@redcrow](https://forums.openmv.io/u/redcrow)
#### Post date: [July 23, 2019, 9:10pm UTC](https://forums.openmv.io/t/plot-profile-function/1360/3 "2019-07-23T21:10:09Z")

</div>

Thanks…Sounds like what I am looking for. I will give that a try.

---

<div class="post-metadata">

### Author: ![redcrow](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@redcrow](https://forums.openmv.io/u/redcrow)
#### Post date: [July 25, 2019, 12:13am UTC](https://forums.openmv.io/t/plot-profile-function/1360/4 "2019-07-25T00:13:38Z")

</div>

I am trying out the x\_hist\_bins() function and getting no data. Is there something wrong calling it on a binarized image?

```python
thresholds = (0, 0)

sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
sensor.set_windowing((300, 120)) # Set 128x128 window.
sensor.skip_frames(time = 2000) # Wait for settings take effect.
clock = time.clock() # Create a clock object to track the FPS.

while(True):
    clock.tick() # Update the FPS clock.

    img = sensor.snapshot()
    img.binary([(110, 255)])
    
    blobs = img.find_blobs([thresholds], pixels_threshold=2000, area_threshold=2000, merge=True)

    num = 0
    for blob in blobs:
        ##uncomment if needed##img.draw_rectangle(blob.rect(), color=127)
        if (blob.w() > 120 and blob.w() < 150) :
            index = blob
            hist = index.x_hist_bins()
            print(len(hist))
            num += 1
        if (blob.w() > 60 and blob.w() < 80) :
            rank = blob
            num += 1
/code]

```

---

<div class="post-metadata">

### Author: ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)
#### Post date: [July 25, 2019, 6:33am UTC](https://forums.openmv.io/t/plot-profile-function/1360/5 "2019-07-25T06:33:29Z")

</div>

You have to pass a flag to find\_blobs() for it to populate the output since this takes a lot of CPU and RAM it doesn’t do it unless asked. Please see the API.

---

<div class="post-metadata">

### Author: ![redcrow](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@redcrow](https://forums.openmv.io/u/redcrow)
#### Post date: [August 28, 2019, 11:14pm UTC](https://forums.openmv.io/t/plot-profile-function/1360/6 "2019-08-28T23:14:52Z")

</div>

Thanks for the help that is exactly what I needed.
