Select labels based on their size
After an image has been segmented and objects are labeled, we may want to remove objects that are either to small or to large to be considered as objects, nuclei for example.
c:\structure\code\pyclesperanto_prototype\pyclesperanto_prototype\_tier0\_device.py:77: UserWarning: No OpenCL device found with GTX in their name. Using gfx1035 instead.
warnings.warn(f"No OpenCL device found with {name} in their name. Using {device.name} instead.")
<gfx1035 on Platform: AMD Accelerated Parallel Processing (2 refs)>
We start from a labeled version of the blobs image.
|
shape | (254, 256) |
dtype | uint32 |
size | 254.0 kB |
min | 0 | max | 63 |
|
Let’s assume we’re not interested in the very small objects as they might be result of a false segmentation of some noise. We do know that the objects we imaged have a certain minimum size. From this physical guess, we need to estimate a number of pixels (in 2D) or voxels (in 3D) object are large. We can then use this number as size_threshold
in pixels or voxels.
|
cle._ image
shape | (254, 256) |
dtype | uint32 |
size | 254.0 kB |
min | 0.0 | max | 52.0 |
|
We can use a similar function to visualize the objects that have been removed above in a separate label image.
|
cle._ image
shape | (254, 256) |
dtype | uint32 |
size | 254.0 kB |
min | 0.0 | max | 11.0 |
|