Morphological operator not working as intended

I am trying to produce the output for the dilation using different structuring elements which are stored in an array. The output works fine when trying to access individual SE in the array, but it does not work when I loop through the array.
Code
strelemLine1 = strel('line', 12, 45);
strelemLine2 = strel('line', 10, 0);
strelemLine3 = strel('line', 15, 45);
strelemSquare = strel('ball',5,5);
strelemDisk = strel('disk',5,4);
strelemDiamond = strel('diamond',5);
structs = [strelemLine1,strelemLine2,strelemLine3,strelemSquare,strelemDisk,strelemDiamond];
dilateResult = zeros(r,c,6);
for i = 1:6
dilateResult(:,:,i) = imdilate(im,structs(i));
end

回答 (1 件)

Jay Bhanushali
Jay Bhanushali 2018 年 10 月 2 日

0 投票

I resolved the issue by using Cell Arrays. Replaced the
dilateResult = zeros(r,c,6);
with:
dilateResult = cell(6);

質問済み:

2018 年 10 月 2 日

回答済み:

2018 年 10 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by