SMIL 1.1.1
|
Images are the basic object type in Smil. Smil was created to manipulate images using mathematical morphology techniques.
Smil Images can basically be declared in one of the following data types :
unsigned integer
of size 8, 16 or 32 bits;Smil images can be of type 1D, 2D or 3D.
From the computer point of view, an image is an instance of a class with two parts :
pixel values : organized as an array. Pixel values can be accessed individually using class methods or by some pointer directly to the array.
When called from Python (module smilPython), Smil images can be handled by Numpy functions or converted in both directions.
Structuring Elements ar just a small set of points used to probe the image under study.
There are some pre defined Structuring Elements :
Blobs are just non connected regions in images. A set of pixels sharing a common property in binary or gray images.
One can use a blob to evaluate parameters of the region : area (count of pixels), volume, statistics (mean, standard deviation, ...), moments, barycenter, inertia matrix, ...
As a data type, a blob is a C++ map
, or Python dict
having the label (region identifier) as a key and a transparent content with all data needed to make calculations on the region.
Blobs can be used directly to get information about regions in a binary image as below :
import smilPython as sp # read input image imIn = sp.Image("balls.png") # label it imLabel = sp.Image(imIn, 'UINT16') sp.label(imIn, imLabel) # compute labels blobs = sp.computeBlobs(imLabel) # get some values on each labelled region areas = sp.blobsArea(blobs) bboxs = sp.blobsBoundBox(blobs)
Or you can use blobs as a mask to get informations about regions in a gray level image. To do that, you should, before all, segment it and get a binary mask.
import smilPython as sp # read input image iName = "https://smil.cmm.minesparis.psl.eu/images/balls.png" imIn = sp.Image(iName) # segment it to create a mask and label binary image imThr = sp.Image(iIn) sp.topHat(imIn, imThr, sp.hSE(20)) sp.threshold(imThr, imThr) imLabel = sp.Image(imIn, "UINT16") # compute blobs from labeled image blobs = sp.computeBlobs(imLabel) # get some values from mask areas = sp.blobsArea(blobs) bboxs = sp.blobsBoundBox(blobs) # get some values on each labelled region barys = sp.blobsBarycenter(imIn, blobs) # mean and standard deviation of pixel values means = sp.blobsMeanVal(imIn, blobs) # first and second moments moments = sp.blobsMoments(imIn, blobs, True) # inertia matrix inertia = sp.blobsInertiaMatrix(imIn, blobs, True)
Some functions available : blobsArea(), blobsVolume(), blobsMoments(),blobsMinVal(), blobsMaxVal(), blobsRangeVal(), blobsValueList(), blobsModeVal(), blobsMeanVal(), blobsBarycenter(), blobsBoundBox(), blobsEntropy() and drawBlobs().