SMIL 1.1.2
Loading...
Searching...
No Matches
blob_measures.py
1from smilPython import *
2
3# Load an image
4imIn = Image("https://smil.cmm.minesparis.psl.eu/images/DNA_small.png")
5imIn.show()
6
7imThr = Image(imIn)
8threshold(imIn, imThr)
9
10imLbl = Image(imIn, "UINT16")
11label(imThr, imLbl)
12imLbl.showLabel()
13
14# Bounding boxes
15bboxes = blobsBoundBox(imLbl)
16imRec = Image(imIn)
17drawRectangles(imRec, bboxes)
18imIn.getViewer().drawOverlay(imRec)
19
20# Blobs measures
21blobs = computeBlobs(imLbl)
22# areas
23areas = blobsArea(imLbl, blobs) # equivalent but faster than measAreas(imLbl)
24# barycenters
25barys = blobsBarycenter(imLbl, blobs)
26# volume of blobs in imIn
27vols = blobsVolume(imIn, blobs)
28print("Label\tarea\tvolume\tbarycenter (x,y)")
29for lbl in blobs.keys():
30 print(str(lbl) + "\t" + str(areas[lbl]) + "\t" + str(vols[lbl]) + "\t" + str(barys[lbl]))
31