0

I am trying to implement a structuring element in MATLAB (disk of radius 2.5).

I'm using the strel function in MATLAB, but by definition the radius must be a positive integer.

Is there any other function that would allow me to do it?

2
  • 1
    strel works on pixels (matrix elements). Those are, by definition, in integers, as there's no such thing as half a pixel or half of a matrix element. Could you please edit the question to elaborate on why you need a radius of 2.5? Perhaps we can then see whether there might be another solution. The first thing that springs to mind for this specific case is to multiply everything by 2, and divide the results by 2 at the end. Commented Sep 21, 2020 at 8:57
  • You can just make your own structuring element. They are just a small matrix. Commented Sep 21, 2020 at 9:55

1 Answer 1

1

It is quite simple to build an image with a disk in it. This image you can use directly as a strel in MATLAB:

r = 2.5;
d = ceil(r);
x = (-d:d).^2;
se = (x + x.') < r.^2; % same as sqrt(x + x.') < r, but cheaper

img = imread('cameraman.tif');
out = imdilate(img,se);

In my PhD thesis I discussed ways to more precisely create disk structuring elements of arbitrary size.

figure from my PhD thesis

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.