[MINC-users] median filter

Andrew Janke a.janke at gmail.com
Sun Jan 30 09:04:41 EST 2011


Hi Francois,

On 29 January 2011 01:16, francois hebert <francois.hebert007 at gmail.com> wrote:
> I wuld like to know if there is a median filter in the minc tool or if
> somebody have it?
> I know that we can specified kernel with mincmoprh but i'm not sure I can
> use mincmorph to perform the median filtering.

I see a bunch of others have thrown all sorts of code at you already
but I'd hate to be left out of this little game so here goes..

There is a median _dilate_ option in mincmorph (dilates by the median
of the values in the structuring element) but from other replies I
think you want to do a median filter on the whole volume?

mincmorph certainly won't be the quickest option but ti will do it via
a convolution kernel. If you want to do a simple 3x3 6-connected
filtering (8 neighbours) I'd do this:

First make a kernel file (file.kern):

---
MNI Morphology Kernel File
%
% 3D 6-connectivity ie: (in 2D)
%
%     1
%   1 0 1
%     1
%
% 0 - center voxel
% Format:  vector for voxel in 5 dimensions (x,y,z,t,v) then multiplier.

Kernel_Type = Normal_Kernel;
Kernel =
%    x    y    z    t    v     coeff
% -----------------------------------
   1.0  0.0  0.0  0.0  0.0     0.166666
  -1.0  0.0  0.0  0.0  0.0     0.166666
   0.0  1.0  0.0  0.0  0.0     0.166666
   0.0 -1.0  0.0  0.0  0.0     0.166666
   0.0  0.0  1.0  0.0  0.0     0.166666
   0.0  0.0 -1.0  0.0  0.0     0.166666;
----

Then use it (note that for each of the 6 neighbors 1/6 of their value
is added to the result).

   $ mincmorph -kernel file.kern input.mnc out.mnc

At least it will work with sufficient speed to see if it works for
you.  As you go to larger elements/filters it will slow down.

have fun.



Andrew


More information about the MINC-users mailing list