How to find all possible small boxes e.g. 2x2x2 and their overlaps within a bigger NxNxN cube?

1 view (last 30 days)
Given an NxNxN cube (image), how can I find all the 2x2x2 boxes within the NxNxN cube? of course if N is even, we can find 2x2x2 boxes without overlapping, but when the N is odd, there is overlapping between some of the 2x2x2 boxes found in the bigger cube.
So,
1- How can I find all the non-overlapped 2x2x2 boxes in a bigger NxNxN cube where N is even?
input: NxNxN cube output: all the possible non-overlapped 2x2x2 cubes.
2- How can I find all the overlapped 2x2x2 boxes in a bigger NxNxN cube where N is odd? This time, the overlapped areas in the 2x2x2 boxes should be zero in second (or more) visits; i.e. each overlapped area should be visited (counted) once not more.
input: NxNxN cube output: all the possible overlapped 2x2x2 cubes with zero values for the overlapped voxels in 2nd or more visits.

Answers (0)

Community Treasure Hunt

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

Start Hunting!