ImageJ max and min filters

11 vues (au cours des 30 derniers jours)
Dante Basile
Dante Basile le 2 Août 2019
Modifié(e) : Dante Basile le 14 Août 2019
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 commentaires
Adam
Adam le 2 Août 2019
Sounds more like a question for an ImageJ forum. Have you asked there?
Dante Basile
Dante Basile le 2 Août 2019
Yes, I have, I was just hoping to come across someone with experience replicating ImageJ operations in MATLAB

Connectez-vous pour commenter.

Réponses (1)

Dante Basile
Dante Basile le 14 Août 2019
Modifié(e) : Dante Basile le 14 Août 2019
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

Community Treasure Hunt

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

Start Hunting!

Translated by