How can I interpolate binary 2D matrices?

2 Ansichten (letzte 30 Tage)
Shyam Sunder Polaconda
Shyam Sunder Polaconda am 13 Jul. 2020
Bearbeitet: Matt J am 13 Jul. 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?

Akzeptierte Antwort

Matt J
Matt J am 13 Jul. 2020
Bearbeitet: Matt J am 13 Jul. 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

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by