Statistics or Histogram of Blob

Hello
I have a project similar to Feasibility of using OpenMV in a bean sorter - Project Discussion - OpenMV Forums "Using OpenMV as a bean sorter.
I have a stream of objects going past and I want to use OpenMV to select which objects fall outside Lab or Histogram sort criteria.
I am a total beginner at OpenMV but using the examples I have code working that will see and track the objects goings past. The idea is that I get the Statistics data or the Histogram data from the Blob, rather than the entire image. This way I should be able to eliminate the “diluting” influence of the background.
I am struggling to find how to return the colour data from the Blob.
Can someone please give me the correct Syntax to return the Blob Statistics or Histogram.
Thanks

Hi, so, just use the rect() method from the blob and feed that to the ROI parameter of get_statistics.

E.g.

Stats = img.get_statistics(roi=blob.rect())

Perfect
That achieved exactly what I wanted.
I can now use
if (stats[0] < 60): #or some other Lab criteria
led.on()
print(“Colour difference detected…”)

In my quick test it worked perfectly and made the discrimination much more sensitive.
Thanks