File Exchange

## imMinkowski

version 1.6 (221 KB) by
Measure of geometric parameters in 2D or 3D images (surface area, perimeter, Euler Number...)

Updated 11 Jan 2021

Contains various functions for measuring or estimating geometric quantities from 2D or 3D images.

Parameters available for 2D images are:
* the area (number of pixels)
* the perimeter (based on Crofton formula)
* the(2D) Euler Number

Parameters available for 3D images are:
* the volume,
* the surface area (measured using the Crofton formula),
* the surface area of the interface between two labels
* the mean breadth (also known as integral of mean curvature),
* the (3D) Euler Number

Most functions work both for binary and label images. It is possible to specify options (connectivity for Euler Number, number of directions for perimeter or surface area), as well as the spatial calibration of images. For some parameters, it is also possible to estimate the density with respect to image area or volume.

Example 1: measure perimeter in 2D label image
p = imPerimeter(lbl)
p =
184.8668 154.9495 185.1921 267.1690 187.3183 179.5038 182.7406 180.8445 155.5049 155.5049

Example 2: measure surface area in 3D binary image
bin = imclose(img>0, ones([5 5 3]));
S = imSurface(bin, [1 1 2.5]) % specify resolution
ans =
2.7291e+004

The latest development version can be found on GitHub within the MatImage project: http://github.com/mattools/matImage .

These functions were developped when writing the following article:
Legland, D.; Kiêu, K. & Devaux, M.-F. Computation of Minkowski measures on 2D and 3D binary images. Image Anal. Stereol., 2007, 26, 83-92, http://www.ias-iss.org/ojs/IAS/article/view/811.

Following reference can also be of interest:
Joachim Ohser and Frank Muecklich (2000) Statistical Analysis of Microstructures in Material Sciences, John Wiley and Sons.

### Cite As

David Legland (2021). imMinkowski (https://www.mathworks.com/matlabcentral/fileexchange/33690-imminkowski), MATLAB Central File Exchange. Retrieved .

David Legland

@agung pratama: it depends on the nature of your image: simple picture? depthmap? A typical workflow would be to first segment the region of interest corresponding to the object, then measure its diameter. In any case, you will need to know the spatial calibration of the image in order to convert pixel measurements into mm. I suggest posting in a general forum (Matlab answers, stack overflow, image.sc...).

agung pratama

Hi David Legland, I'm a newbie in Matlab. I have a 3D surface from a 2D image of an object, f I want to know the hight of 3D surface in mm how I can do that?

David Legland

Hi Tammy,

yes, the choice of connectivity can make a difference, especially if the images contain a lot of small details. You can also preprocess the data with morphological opening and/or closing, to remove structures or holes that are too small.

The behaviour on the border of image can be relevant too. You need to check how Avizo manages borders. In this Matlab contribution, the function "imEuler3d" considers that the structure is isolated from border (one should obtain the same result by padding image with '0'), and the function "imEuler3dEstimate" uses edge correction such that euler density can be computed by dividing with the measured volume.

Tammy Amirian

Hi David,
I tried to calculate the (3D) Euler Number for a 3D image using your MATLAB codes and Aviso. Aviso calculate the number to be -928 and MATLAB code generated -3000. The difference is quit significant and I thought it might be due to different connectivity number or the equation applied in MATLAB and AVISO. Do you think is that the case?

David Legland

Hi George Chang,
exactly, I meant the boundary of the image. So if there is not 'white' pixel at the boundary, the result of imEuler3d and imEuler3dEstimate will be the same.

George Chang

Dear David,
Thank you for your reply. Could I ask that the edge of image you mention is the boundary of the image or the boundary of the object? For example, if today I have a 3D solid box which is 10 pixels in length, width and height in the middle of 100 pixels x 100 pixels x 100 pixels 3D image stack, should I get the same result from imEuler3d and imEuler3dEstimate since there is nothing on the corners, on the edges, on the faces of 3D image stacks? Thank you very much.

David Legland

Hi George Chang,
The difference relies in the way image edges are managed.
* In imEuler3d, no edge correction is made -> the result will be the same even if some voxels touches the image edges (ie, some pixels are located on one of the boundary planes).
* in imEuler3dEstimate, different weights are associated to voxels on the corners, on the edges, on the faces, and inside the image. This allows to estimate densities of Euler number for porous media for example.
More details can be found in the book from Ohser and Muecklich, or the book "3D image analysis of Material Structures" from J. Ohser and K. Schladitz.

George Chang

Dear David,

Could I ask what's the difference between function imEuler3d and imEuler3destimate? Also what is mean edge correction for? Thank you very much.

David Legland

Hi Irina,
thank you for your interest in the package! The choice of values for center were primarily to avoid artifacts due to the sampling of a ball perfectly on a grid. In that case, the resulting discretization is prfeclty symmetric, and the value of voxels located along main axes change all together of one increase the radius of a very small amount. Using a slightly shifted center avoids symmetry artifacts, and makes the discretization change more regularly when radius increases. The chosen values are totally arbitrary, I just tried to have different shifts along dimensions.

Irina Makarenko

Dear David,
Thanks a lot for your packages! Very useful!
I am looking at imSurface function from this package. You gave an example in it, where you create a binary image of a ball
% [x y z] = meshgrid(1:100, 1:100, 1:100);
% img = sqrt( (x-50.12).^2 + (y-50.23).^2 + (z-50.34).^2) < 40;
Why did you choose the coordinates of the ball centre as 50.12, 50.23 and 50.34. I realised that such choice improve the results making it closer to theoretical one, but why 12, 23 and 34 as decimal values?

David Legland

Hi Amit,
For volume, area, surface area and perimeter there are theoretical bounds on the maximum errors that can be obtained. Most of the details are in the paper published in IAS in 2007.

For Euler Number and Integral of Mean Curvature (or mean breadth), I have no theoretical bounds.
Hope this helps ?

Amit Seta

Amit Seta

Hello,

Is it possible to estimate the errors associated with the calculated Minkowski functionals?

Thanks,
Amit

David Legland

Hi Sarvenaz,
This package is for intended to compute Minkowski functionals from 2D/3D discrete images. Your data consist in 3D geometrical points or meshes, so it is not the most appropriate solution. For computing volume, there is an option in the convhulln function.
You can try to use the package "geom3d" that I also released: the function "meshSurfaceArea" should give you the surface area of the mesh, and the function "trimeshMeanBreadth" will compute the mean breadth of the resulting mesh. Euler number of a convex set equals one by definition.

Hope this helps ?

sarvenaz babakhani

i have some scattered points , by using convhull and trisurf ,plot the convexhull
how can i use your package for calculating minkowski functional?

David Legland

Hi Hamidreza,
You're right! in fact, the intersectLineSphere function is part of the geom3d package, and I forgot to update the dependency. It is update inthe new 1.5 version of imMinkowski!

David Legland

Hi Akshay,
This package is devoted to the analysis of 3D images represented as 3D grids of values / voxels. The obj file format corresponds to polygonal meshes. You should rather use mesh-oriented functions. I have packaged some of them in the geom3d library (for example "meshSurfaceArea"), but there are many other submissions.

In intersectLineSphere, line 39, I guess
"by elseif abs(delta) > 1e-14"
you meant "elseif abs(delta) < 1e-14" right?

Akshay Desai

I want to analyse the surface area, volume, and angle of a 3D image that is an obj. file, can this be done?

David Legland

Hi Leonard,
yes, there are four Minkwoski functionals for 3D structures. They are implemented in this submission as imVolume, imSurface, imMeanBreadth (related to the integral of mean curvature), and imEuler3d (related to integral of gaussian curvature, and to Euler number in 3D...).
Regards!

Leonard

Hello David,

I am attempting to calculate the Minkowski Functionals for a set of clustered 3D volumes and in my research for definitions of the Minkowski Functionals I came upon this MFEX submission.

To preface my question, it is well known that in 2D systems there are three total Minkowski Functionals: the cluster SA, the cluster perimeter, and the Euler Number (number of clusters - number of holes). Based on the general definition of the Minkowski Functionals that I currently have, there should therefore be 4 functionals for 3D clusters: cluster volume, cluster SA, and two more. One of these is certainly related to the Euler number in 3D.

Does the program which you have developed calculate these 3rd and 4th quantities? If so, could you fill me in on how they are defined (in layman's terms)?

Thanks!
Lenny

David Legland

Hi Amir,
I suppose you have acquired 3D images. Functions of this package work with binary images, so you need to binarize (segment) them. Then the volume of each cylinder is the number of voxels. If you want the volume in metric unit, you need to multiply by the product of resolutions in each direction (to have the volume of an individual voxel). But if you just want to compare the volumes, I suppose you can consider the ratio of the volumes in pixels after and before the deformation?

amir meh

Hi David
Assume we have two images from a cylindrical specimen before and after deformation (during this deformation the volume of the sample has been changed). we know the initial volume of the sample and the deformation occurs symmetrically. so we can assume that the 2D image of this sample shows a central section of specimen. the overall sample volume is obtained by representing the sample as a series of stacked circular disks. for each disk, it is assumed that the thickness of the disk is equal to a vertical pixel, while the diameter is equal to the number of horizontal pixels of each disk. so the volume of each disk can be calculated by (pi*((number of horizontal pixel)^2)/4*one pixel (the height of a disk)). the volume of the sample is calculated as the sum of the volume of the disks. by knowing the initial volume of sample we can calibrate the calculated volume of sample in first image (before deformation). now we want to convert the calculated volume of sample in image 2 (after deformation) from pixel to engineering unit and compare it to initial volume. the question is how we can do that in MATLAB. do you have any idea?

David Legland

@Amir:
There are examples on the FEx page, as well as on the main help page when you type "help imMinkowski". There are also working examples on (quasi) each function in the library, you can get them by "help imSurface", for example.

amir meh

that would be a good idea if you could provide some examples and procedure for your code.

David Legland

@Hamed:
It will be difficult for me to answer your question... I think you should ask your question in more appropriate location, such as Matlab Answers, StackOverflow.com, or similar forums.

David Legland

Hi Mike,
you can have a look at the paper for which I wrote this contribution:
Legland, D.; Kiêu, K. & Devaux, M.-F. Computation of Minkowski measures on 2D and 3D binary images Image Anal. Stereol., 2007, 26, 83-92, http://www.ias-iss.org/ojs/IAS/article/view/811

You can also find resources in the book "Statistical Analysis of microstructures in Material Sciences", by J Ohser and F. Muecklich (they provide some C code too).
regards,
David

hamed

I have a problem.Any body can help me please?!
I have a series of images of a blood clot in the coronary artery angiography .(These photos are from different angles and different thicknesses of clot) .I want process these two-dimensional images to estimate the VOLUME of the clot anymore. please help me!
thank you so much....

Any idea?
hamed_eisaie@yahoo.com

Mike

Hello, I am using your method "imMeanBreadth" for a school project, but I need to know the formula. Can you please also provide your reference?
Thank you!

David Legland

Hi Sara,
For 3D objects you can compute surface area or volume using following code:
surf = imSurface(BIN); vol = imVolume(BIN);
(assuming BIN is a logical array containing the binarisation of the structure).

You can specify resolution as a 1-by-3 row vector containing size of voxel in x, y and z directions. Ex:
surf = imSurface(BIN, [2.5 2.5 5.2]);

sara

hi , may you give the complite code for measuring 3D size of the object located in calibrated space please ? any one

Ashok Kumar Pant

It helps me for feature Extraction from Handwritten Characters. Thank you Devid.

David Legland

Hi Sven,
I have a code for computing inertia ellipsoid of a set of points. I can adapt it easily to compute inertia ellipsoid of a binary image. I try to package it and submit it soon !

Sven

Hi David, the ability to specify image resolution is a big plus. Nice work. One thing that I find is that I wish the regular IP "Orientation" and "Majory/MinorAxis" statistics could be implemented for 3D. For instance, from a 3D mask I generally want to know "is this a long thin blob or a more rounded blob". Basically, the moments of inertia of the blob would be hugely helpful. Any plans to implement this?

##### MATLAB Release Compatibility
Created with R2020a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux