필터 지우기
필터 지우기

is an ellipse-shaped structuring element possible

조회 수: 10 (최근 30일)
soepblik
soepblik 2021년 10월 5일
편집: DGM 2021년 10월 5일
I was wondering if it is possible to create an ellipse-shaped structuring element in matlab?

채택된 답변

DGM
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);
I'm sure there are other ways as well.
MIMT can be found on the File Exchange.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by