![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/758656/image.png)
is an ellipse-shaped structuring element possible
24 ビュー (過去 30 日間)
古いコメントを表示
採用された回答
DGM
2021 年 10 月 5 日
編集済み: DGM
2021 年 10 月 5 日
It's possible, just not with strel().
% build test image
testsz = [35 35]
A = false(testsz);
A(ceil(testsz(1)/2),ceil(testsz(2)/2)) = true;
% specify filter size
filtsz = [15 25];
% a flat disk strel (not quite a circle)
s0 = strel('disk',6);
B0 = imdilate(A,s0);
% stretch out the prior filter (not quite an ellipse)
s1 = imresize(s0.Neighborhood,filtsz);
B1 = imdilate(A,s1);
% make a strel from a numeric filter
% this uses fkgen() from MIMT, since fspecial() can't do this
s2 = simnorm(fkgen('disk',filtsz))>0;
B2 = imdilate(A,s2);
% make a strel from scratch
szf = round((filtsz+1)/2)*2-1; % round to nearest odd integer
[xx yy] = meshgrid(1:szf(2),1:szf(1));
s3 = ((xx-ceil(szf(2)/2))/(szf(2)/2)).^2 + ((yy-ceil(szf(1)/2))/(szf(1)/2)).^2;
s3 = s3<1;
B3 = imdilate(A,s3);
C = cat(2,B0,B1,B2,B3);
imshow(C);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/758656/image.png)
I'm sure there are other ways as well.
MIMT can be found on the File Exchange.
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!