How can we perform erosion adn dilation operations in 3d in matlab?
Are there any functions in matlab to perform erosion and dilation of a
3d image? If then, what are they?
Thanks,
Anand.
Almost all of the morphological functions in the Image Processing
Toolbox can work in any number of dimensions. Use imdilate and imerode.
--
Steve Eddins
http://blogs.mathworks.com/steve
Thanks. DX
Is it binary erosion? If so, you can get the equivalent by doing
result = convn(logical(A),[1 1 1;1 1 1;1 1 1]/9,'same')>=1
Since [1 1 1;1 1 1;1 1 1] is also separable, you can accelerate computation, possibly, by doing the convolution separably.
[1 1 1;1 1 1;1 1 1] is a square strel, not a cube. ones(3,3,3) is a cube.
>> a = zeros(3,3,3);
>> a(2,2,2) = 1
a(:,:,1) =
0 0 0
0 0 0
0 0 0
a(:,:,2) =
0 0 0
0 1 0
0 0 0
a(:,:,3) =
0 0 0
0 0 0
0 0 0
>> imdilate(a,ones(3,3,3))
ans(:,:,1) =
1 1 1
1 1 1
1 1 1
ans(:,:,2) =
1 1 1
1 1 1
1 1 1
ans(:,:,3) =
1 1 1
1 1 1
1 1 1
---
Steve Eddins
http://blogs.mathworks.com/steve/