ImageJ max and min filters

I have been using the max and min filters in ImageJ to erode and dialate images.
Now I am trying to replicate this functionality in MATLAB.
Using Square matrixes for the neighborhood, the imerode and imdialate results are not as "smooth" as what ImageJ produces.
What extra technique is ImageJ using to produce "smooth" erosions?

2 comentarios

Adam
Adam el 2 de Ag. de 2019
Sounds more like a question for an ImageJ forum. Have you asked there?
Dante Basile
Dante Basile el 2 de Ag. de 2019
Yes, I have, I was just hoping to come across someone with experience replicating ImageJ operations in MATLAB

Iniciar sesión para comentar.

Respuestas (1)

Dante Basile
Dante Basile el 14 de Ag. de 2019
Editada: Dante Basile el 14 de Ag. de 2019

0 votos

This is the function I have come up with for replicating the masks used by ImageJ
function[kMask] = ijRadMask(radius)
% IJRADMASK get mask for imerode/imdilate which is identical to the one used by imageJ for erosion/dilation
% input: radius in pixels to be eroded/dilated
% output: disk mask for erosion/dilation
r2 = floor(radius^2 + 1); %simulate java int conversion
kRadius = int32(floor(sqrt(r2 + 1e-10)));
kernel = int32(zeros(kRadius + 1, 1));
kernel(kRadius + 1) = kRadius; %set kernel center
for y = 1:double(kRadius) %make kernel
dx = int32(floor(sqrt(r2 - y^2 + 1e-10)));
kernel((kRadius + 1) - y) = dx;
end
kMask = zeros(kRadius*2 + 1); %mask for filter
kHeight = 2*kRadius + 2;
mCenter = kRadius + 1;
kMask(mCenter, 1:size(kMask, 2)) = 1; %horizontal line through center
for i = 1:(size(kernel, 1) - 1)
kMask(i, (mCenter - kernel(i)):mCenter + kernel(i)) = 1;
kMask(kHeight - i, (mCenter - kernel(i)):mCenter + kernel(i)) = 1;
end
end

Categorías

Más información sobre Read, Write, and Modify Image en Centro de ayuda y File Exchange.

Preguntada:

el 2 de Ag. de 2019

Editada:

el 14 de Ag. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by