within a 3D binary matrix, finding the largest (volume-wise) sub matrix, that has at least X% TRUE pixels

1 view (last 30 days)
I'm trying to find a general solution to the problem at the headline. here is an example:
create a 3d matrix with a large object and some change:
samp3D = false(200,200,200);
samp3D(10:90,10:90,10:90) = true; % create a large cube
samp3D(30:120,10:40,5:15) = true; % create x-axis projection
samp3D(80:100,40:150,40:90) = true; % create y-axis projection
samp3D(60:80,60:70,10:end) = true;samp3D(30:40,30:50,10:120) = true; % create z-axis projections
samp3D(60:90,120:150,120:150) = true;samp3D(120:150,10:40,120:150) = true; %add 2 small cubes
samp3D(randi(200*200*200,10000,1)) = true; %add some noise
Now, when dividing the number of TRUE indices with the number of all indices we get about 9.3%:
TruePercent = sum(samp3D(:))/numel(samp3D(:)); %TruePercent comes to about ~9.3%
What is the largest (volume-wise) sub-matrix within the 3D matrix that has TruePercent of at least 40%?

Answers (0)

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!