BlobStats
BlobStats is a GIMP plug-in for calculating and reporting statistics on "blobs" in images. Roughly speaking, it does the following:
- Find each individual "blob" with intensity above a given threshold.
- Calculate the zeroth (area), first (centroid) and second (width) moments of each blob.
- Create different colored shapes for each blob against a transparent background (if drawable is RGB not grayscale).
- Draw lines using the current brush, foreground color and opacity representing the major and minor axes of the ellipsoid fitting each blob based on its second moments, and centered at its centroid.
- Optionally save each blob's moment statistics, along with derived properties such as aspect ratio and orientation angle, in a CSV (comma-separated values) file for later processing using spreadsheet software.
This has many potential uses in materials science, for example:
- Calculate the density and spatial distribution of precipitates or grains (if grain boundaries are sufficiently clear).
- Calculate particle size mean and standard deviation, or plot a histogram.
- Run regressions to determine the strength and statistical significance of correlations, e.g. aspect ratio vs. location, size vs. orientation.
Keep in mind that such 2-D correlations don't always reflect the nature of the 3-D structure.
Embedding this within GIMP brings along all of its tools, for example:
- One can set the foreground color, brush and opacity to any values, these are used to draw the ellipsoid axes.
- It can be helpful to duplicate a layer before using BlobStats; the resulting blobs and axes look compelling against the original background.
- Grainy images can probably go through a blurring process before using BlobStats (see Filters -> Blur for some examples).
- To find dark blobs in a bright background, use Colors -> Invert before using BlobStats.
- Use other Edge-Detect filters to convert the detected blobs to outlines.
Compilation Instructions
On Debian, Ubuntu and other Debian-based systems, install the packages libgimp2.0-dev, libc6-dev and gcc. Then type:
gimptool-2.0 --install blobstats.c
(Ignore the "no previous prototype" warnings, this single-file plugin doesn't need prototypes.) When GIMP next starts, the Filters -> Edge-Detect menu should now have an entry for BlobStats. You can re-compile and re-install it on the fly without quitting GIMP.
Bugs
- I can't for the life of me figure out how to draw the axes on the preview window.
- It should be made clearer that BlobStats draws the axes using the current brush.
Future Possibilities
In roughly decreasing order of priority:
- Use GIMP's units (pixels per inch/millimeter) to calculate moment integrals -- which will alter the second moment calculations in ways that can't be corrected on the spreadsheet.
- Compile the Windows plug-in and upload it here, as it's much more difficult than compiling on Linux.
- Have blob parameters, such as orientation, aspect ratio and size, determine the blob color.
- Replace string entry with a proper file dialog to select the CSV file name.
- Include a brush selector button in the plug-in.
- Select the channel for finding blobs and calculating moments from intensity, alpha, red, green, blue. This is already possible by using GIMP tools beforehand, but it might be nice to have in the plug-in itself.
Attachments
-
blobstats-1.0.c
(25.7 kB) - added by powell
2 years ago.
BlobStats 1.0 release C source file
-
blobstats.jpg
(100.0 kB) - added by powell
2 years ago.
Image made by BlobStats (original from Arcelor Mittal)
