Plot Profile function

OpenMV related project discussion.
redcrow
Posts: 10
Joined: Wed Jul 17, 2019 7:28 pm

Plot Profile function

Postby redcrow » Mon Jul 22, 2019 7:22 pm

Is there something similar to the Plot Profile function of ImageJ (with a rectangle) https://imagejdocu.tudor.lu/doku.php?id ... ot_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.
User avatar
kwagyeman
Posts: 4457
Joined: Sun May 24, 2015 2:10 pm

Re: Plot Profile function

Postby kwagyeman » Tue Jul 23, 2019 12:43 am

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().
Nyamekye,
redcrow
Posts: 10
Joined: Wed Jul 17, 2019 7:28 pm

Re: Plot Profile function

Postby redcrow » Tue Jul 23, 2019 5:10 pm

Thanks...Sounds like what I am looking for. I will give that a try.
redcrow
Posts: 10
Joined: Wed Jul 17, 2019 7:28 pm

Re: Plot Profile function

Postby redcrow » Wed Jul 24, 2019 8:13 pm

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

Code: Select all

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]
User avatar
kwagyeman
Posts: 4457
Joined: Sun May 24, 2015 2:10 pm

Re: Plot Profile function

Postby kwagyeman » Thu Jul 25, 2019 2:33 am

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.
Nyamekye,
redcrow
Posts: 10
Joined: Wed Jul 17, 2019 7:28 pm

Re: Plot Profile function

Postby redcrow » Wed Aug 28, 2019 7:14 pm

Thanks for the help that is exactly what I needed.

Return to “Project Discussion”

Who is online

Users browsing this forum: No registered users and 7 guests