Is there something similar to the Plot Profile function of ImageJ (with a rectangle) tudor.lu? 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.
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().
Thanks…Sounds like what I am looking for. I will give that a try.
I am trying out the x_hist_bins() function and getting no data. Is there something wrong calling it on a binarized image?
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]
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.
Thanks for the help that is exactly what I needed.