How to Sort the Values of the Window? #13
Unanswered
RoyiAvital
asked this question in
Q&A
Replies: 1 comment
-
I ended up doing: function OrderFilter( mI :: Matrix{T}, tuBoxRadius :: Tuple{N, N}, k :: N ) where {T <: AbstractFloat, N <: Integer}
# Similar to MATLAB's `ordfilt2()`.
# Should be used with a small radii.
numElements = (N(2) * tuBoxRadius[1] + one(N)) * (N(2) * tuBoxRadius[2] + one(N));
vB = zeros(T, numElements);
mK = Kernel{(-tuBoxRadius[1]:tuBoxRadius[1], -tuBoxRadius[2]:tuBoxRadius[2])}(@inline w -> (copyto!(vB, Tuple(w)); sort!(vB)[k]));
mO = map(mK, extend(mI[:, :, 1], StaticKernels.ExtensionSymmetric()));
return mO;
end I guess it is more efficient as memory is allocated only once. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to build something similar to MATLAB's
ordfilt2()
:Th issue I get is:
Even if I use
(@inline w -> sort(w)[k]);
I get:Any idea how to get through this?
Beta Was this translation helpful? Give feedback.
All reactions