Filter löschen
Filter löschen

is an ellipse-shaped structuring element possible

10 Ansichten (letzte 30 Tage)
soepblik
soepblik am 5 Okt. 2021
Bearbeitet: DGM am 5 Okt. 2021
I was wondering if it is possible to create an ellipse-shaped structuring element in matlab?

Akzeptierte Antwort

DGM
DGM am 5 Okt. 2021
Bearbeitet: DGM am 5 Okt. 2021
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.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by