-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Hey,
I noticed that when I apply filters to the list of detected blobs and only one blob is in the list, this blob will not be returned even though it is within the filter criteria. I am not sure if that behavior is intended, but for my applications at least it's unfortunate.
Consider this minimal example:
from machinevisiontoolbox import Image
from matplotlib import pyplot as plt
img = Image.Zeros(1000, dtype="uint8")
img.A[300:400, 200:300] = 255
#img.A[100:105, 100:105] = 255
img.disp(block=False)
blobs=img.blobs()
print(blobs)
print('Blob_0 area:')
print(blobs[0].area)
blobs.plot_box(color='g')
blobs.plot_centroid(label=True)
plt.show(block=True)
blobs_filtered = blobs.filter(area=100)
print("Filtered blobs:")
print(blobs_filtered)The terminal output is:
So even though the blob has an area > 100 it is not returned from the filtering.
When applying the same filter with two detected blobs, everything works fine.
A potential fix is in ImageBlobs.py, Line 482 to flatten the mask variable m:
return self[m] -> return self[m.flatten()]
Metadata
Metadata
Assignees
Labels
No labels