No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

4.8 | 4 ratings Rate this file 12 Downloads (last 30 days) File Size: 3.29 KB File ID: #22044 Version: 1.3




10 Nov 2008 (Updated )

Performs 3D order-statistic filtering on 3D volumetric data.

| Watch this File

File Information

ordfilt3: Performs 3D order-statistic filtering on 3D volumetric data.

The memory and computational overhead for such an operation can be extremely demanding. Here - memory efficiency has been achieved with a recursive-split algorithm, allowing for far larger volumes and/or window sizes to be processed than if the order statistics were to be attempted directly. The basic operation is fairly simple - the volume is recursively split into 8 even sub-blocks, until sub-blocks are reached that are small enough for the filter to be computed with a single call (i.e. when there is enough free contiguous memory to process the entire sub-block) The intermediate results are propagated back up the call stack which then fill output matrix (V_ord)

[V_ord] = ordfilt3(V0,ord,winSize,pad_opts)

 V0: Numeric 3D volume. Supports all numeric classes
 ord: Speficies which order statistic to return.
          This can be a string, or a number 1<=ord<=winSize^3
          For example:
          ord = 'min' returns the minimum window value (same as ord = 1)
          ord = 'max' returns the maximum window value (same as ord = winSize^3)
          ord = 'med' returns the median window value

winSize: Size of filter window. Currently, only cubic windows are permitted, whose
             Length=Width=Height = winSize. This must be odd.

pad_opts: same as defined in 'padarray' (optional)

V_ord - Order Statistic

By calling [V_ord] = ordfilt3(V0,ord,3,pad_opts), this code computes the 26-neighbourhood order statistic filter, which is the same as outputted by Olivier Salvado's implementation (but which is non-splitting, and uses a fixed 3*3*3 window.)


Ordfilt3 inspired this file.

This file inspired Spherical Hough Transform For 3 D Images.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
14 Mar 2013 Keith

Keith (view profile)

Great! almost 40% faster than medfilt3. Following Matthias's memory suggestion, an alternative for other platforms is largestmemblock

Note: You do need to modify that function in order to actually return the value.

15 Apr 2011 Matthias Schabel

I suggest a couple of minor changes :

1) Insert the following two lines after line 50 to get reasonable default values :

if (nargin < 3) winSize = 3; end;
if (nargin < 2) ord = 'med'; end;

2) Replace M = feature('memstats'); (which only works on Windows) with

M = feature('memstats');
catch e
M = 10^28; % or however many bytes of free space you figure your machine will have

Comment only
15 Apr 2011 Matthias Schabel

29 Jun 2010 Juha-Matti Alakoskela

27 Nov 2009 Shripad Kondra

Thanks !

26 Sep 2009 Ganesh

Ganesh (view profile)

Very useful. I like the display of memory allocation. Is there a 3D median filter where the user can set unequal window sizes along the 3 directions?

Comment only
10 Nov 2008 1.1

Header comments updated

13 Nov 2008 1.3

Detailed function description uploaded

Contact us