Distance Transform in 3D

1 次查看(过去 30 天)
Sumayyah Alhydary
Sumayyah Alhydary 2021-4-24
Hello everyone!
Background:
Let us say I have 4 binary 5x5 matrices:
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
0 0 0 0 0
0 1 1 0 0
0 1 1 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 1 1 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 1 1 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
Imagine that we stack all of them on top of each other (first one is at the bottom).
The propuse of them is they explain the density of each position in a 5x5 image:
If we sum the 1's for each position, that gives us the density of that position.
For example:
  • the density of the position where the bolded 1 is will be 2 (it appears in the first matrix and second matrix)
  • for the underlined 1's will be 4 for all three positions (they apears in all 4 matrices)
  • all of the other position's density is 1 (apears only in first matrix).
resulting in the following 5 x 5 matrix with maximum density of 4:
1 1 1 1 1
1 4 4 1 1
1 4 2 1 1
1 1 1 1 1
1 1 1 1 1
Quesiton:
If have 100 binary 512x512 matrices and I want to calculate the distance transform for each one of the 100, how can I do that?
I found the following figure online and I will use it as another example:
Imagine here that we have 11 matrices and the first one is all 1 (that's why the bottom row in the following figure is all colored).
The tail of the arrow is assigned the distance to the boundary of the object as indicated by the tip of the arrow.
Guidelines:
  • All positions have a value of 1 in the first matrix.
  • If a position value changed from 1 to 0, it will not change back to 1 later.
Thanks in advance.
And in case you're wondering ..
I'm trying to implement the interpolation exaplained in "Shape-Based Interpolation of Multidimensional Grey-Level Images" By George J. Grevera.

回答(1 个)

Image Analyst
Image Analyst 2021-4-24
The distance transform is not just the summing along the third dimension. Since you say you want to sum along the third dimension of your 512 x 512 x 100 matrix, why not simply do
image2DSum = sum(image3D, 3); % Sum along dimension #3.
  1 个评论
Sumayyah Alhydary
Sumayyah Alhydary 2021-4-24
编辑:Sumayyah Alhydary 2021-4-24
Thanks for your responce and sorry I didn't explain the problem correctly. I just edit it the questoin.
The sum will give me the density for that pixel (which I will use later to decide the gray-level for that pixel)
But now, I need to find the distance transform matrix for each "layer" or matrix of the given 4.
So in the figure I showed above, I need to find the shortest distance to the top for each colored cell.
(What i'm trying to do in my probject is to have two gray-scaled images > convert each to 3D by doing what I did in the 5x5x4 example > apply distance transformation to each layer > apply interpolation on the distance matrices > collapse them back to 2D. Now I have an interpolated image between these two images)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by