MATLAB: How to calculate volume fraction in small blocks in the stack of 2D binary images

stack imagesvolume fraction

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?

Best Answer

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);
You can divide the stack into small blocks using array indexing.