How to calculate volume fraction in small blocks in the stack of 2D binary images?
2 views (last 30 days)
Show older comments
I have a 2D stack of binary images. I want to divide 3D volume in small blocks and calculate volume fraction in each block. Does anyone have suggetions how can this be done?
0 Comments
Accepted Answer
Raunak Gupta
on 18 Jul 2020
Hi,
As mentioned in this Answer, you can calculate the volume fraction as fraction of count of non-zero pixel values to the total number of pixels in the volume Image. Let's say a small block of 2D images is a 3D matrix Image then volume fraction can be calculated as
volumeFraction = nnz(Image)/numel(Image);
3 Comments
Walter Roberson
on 18 Jul 2020
In some cases, it makes sense to fit a surface around a series of connected blocks in order to obtain a better estimate of the volume fraction.
Consider, for example, the case of a discretized sphere in a box that extends the same distance further in X, Y, Z. If you were able to figure out that it was a sphere and its size, then you could find the theoretical volume and compare that to the volume of the containing area to get the fraction. Now take the same structure but use a coarser and coarser discretization. The limiting case is that you would end up with a single cubic block at the center of a 3 x 3 grid, for a volume fraction of 1/27, about 0.037 -- but if you knew it was a sphere then you would get the volume fraction 4/3*pi*(1/2)^3 / 27, about 0.019. Actual volume of the sphere is about 0.524 of the fully-coarse representation of it.
See for example the difference between the area calculation of bwarea() https://www.mathworks.com/help/images/ref/bwarea.html compared to just plain number of pixels that are "on".
Raunak Gupta
on 19 Jul 2020
Edited: Raunak Gupta
on 19 Jul 2020
Hi Walter,
It's a Nice idea to use bwarea here as it will give much more accurate solution. But again since any image will have a limited resolution, so there will always be a uncertainity around what is the actual ratio and it depends on the image quality in which the data is stored.
More Answers (0)
See Also
Categories
Find more on 3-D Volumetric Image Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!