How can I interpolate binary 2D matrices?

7 visualizaciones (últimos 30 días)
Shyam Sunder Polaconda
Shyam Sunder Polaconda el 13 de Jul. de 2020
Editada: Matt J el 13 de Jul. de 2020
I am not sure if this is entirely possible, but I am trying to do this:
For a 3d matrix with some number of layers in the z dimension,
The user should input the location of a region (marked by value of 1) in the first layer, and last layer, and the goal is to have matlab fill in the intermediate regions.
for example
layer1 = [1 1 1 1 1; ...
1 1 1 1 1; ...
1 1 1 1 1; ...
1 1 1 1 1; ...
1 1 1 1 1]
layer3 = [0 0 0 0 0; ...
0 0 0 0 0; ...
0 0 1 0 0; ...
0 0 0 0 0; ...
0 0 0 0 0]
the layer in between the 2 should be filled by matlab and have the following output
layer2 = [0 0 0 0 0; ...
0 1 1 1 0; ...
0 1 1 1 0; ...
0 1 1 1 0; ...
0 0 0 0 0; ...]
This would be a very very simple case. Ideally I am trying to make this work for a 3d matrix with dimensions probably ranging from 500*500*500 to 2000*2000*2000
Is there any function in matlab that would help in this process?

Respuesta aceptada

Matt J
Matt J el 13 de Jul. de 2020
Editada: Matt J el 13 de Jul. de 2020
If the final, filled in region is convex, it can be obtained as follows
layers=false(5,5,3)
layers(:,:,1)=1;
layers(3,3,3)=1;
T=regionprops3(double(layers),'ConvexImage','SubarrayIdx')
layers(T.SubarrayIdx{:})=T.ConvexImage{1}
layers(:,:,1) =
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
layers(:,:,2) =
0 0 0 0 0
0 1 1 1 0
0 1 1 1 0
0 1 1 1 0
0 0 0 0 0
layers(:,:,3) =
0 0 0 0 0
0 0 0 0 0
0 0 1 0 0
0 0 0 0 0
0 0 0 0 0

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by