How can I interpolate binary 2D matrices?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Shyam Sunder Polaconda
le 13 Juil 2020
Modifié(e) : Matt J
le 13 Juil 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?
0 commentaires
Réponse acceptée
Matt J
le 13 Juil 2020
Modifié(e) : Matt J
le 13 Juil 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
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!