1
import diplib as dip
from matplotlib import pyplot as plt
#reading video
vid = dip.ImageReadICS(r'C:\Users\mrtij\.spyder-py3\20211123_152822_capture.ics')
vid = vid[0:-1, 0:-1, 325:3149]
smvid = dip.Gauss(vid, [2,2,0])

for i in range(1000, 1001):
    img = smvid[0:-1, 0:-1, i]

    imgmask = dip.IsodataThreshold(img)
    imgmask = dip.Label(imgmask)

    measuremnt = dip.MeasurementTool.Measure(imgmask, img)
    print(measurment)

I am trying to find positions and sizes of blobs on a relatively low res video, the 20211123_152822_capture.ics file. First I add a smoothing filter and then two masking filters. The MeasurementTool.Measure function however, only returns sizes and not the positions of my blobs. I can't find how to fix this and thought maybe someone here could be of help. Edit: I only view a single frame here, I plan on saving the coordinates of each blob on each frame, hence the for loop.

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
  • By the way: you are more likely to get an answer here if you use the right tags. Tags is what people filter questions on that they might be able to answer. – Cris Luengo Dec 12 '21 at 21:05

1 Answers1

1

Figured it out, needed to use MeasurementTool.Measure(imgmask, img, ['Size', 'Gravity'])

  • “Size” gives you the size of the binary shape, “Mass” gives you the gray-scale “size”, the integral over the Gaussian blob. Likewise, “Center” gives you the centroid of the binary shape, “Gravity” gives you the gray-scale centroid. The gray-scale measurements are typically more precise when measuring Gaussian blobs. You can even grow your labeled image a bit to improve precision ([GrowRegions](https://diplib.org/diplib-docs/regions.html#dip-GrowRegions-dip-Image-CL-dip-Image-CL-dip-Image-L-dip-sint--dip-uint-)). – Cris Luengo Dec 12 '21 at 21:03