View License

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

» Watch video

Highlights from
Masked k-order statistic filters for 2D data

1.5 | 2 ratings Rate this file 4 Downloads (last 30 days) File Size: 619 KB File ID: #36686 Version: 1.6
image thumbnail

Masked k-order statistic filters for 2D data



14 May 2012 (Updated )

Morphological erosion, dilation, median filter and generic k-order statistic filter implementation

| Watch this File

File Information

Masked k-order statistic filter for double data

refer to: F. Bellavia, D. Tegolo, C. Valenti, "Improving Harris corner selection strategy", IET Computer Vision 5(2), 2011. Only for academic or other non-commercial purposes.

With respect to standard matlab routines, any kernel mask can be used and it is faster for large kernel size (i.e. more than 30x30 kernel mask)

im - input 2D matrix
ker - kernel binary mask
idx - k-order index, in range [1,sum(ker(:)))

Use idx=1 for min filter (graylevel erosion), idx=sum(ker(:))/2+0.5 for median filter, idx=sum(ker(:)) for max filter (graylevel dilation), any other value for k-selection filter, non integer values interpolate between values, i.e. 5.6 give 0.4*I(5)+0.6*I(6) where I(n) is the n-th values in the sorted order inside the kernel mask.

r - result 2D matrix, of the same size of im, zero padding is used for the border.

The median filter implementation is based on:
W. Hardle, W. Steiger, "Algorithm AS 296: Optimal Median Smoothing", Journal of the Royal Statistical Society, Series C (Applied Statistics), pp. 258-264.

Required Products MATLAB
MATLAB release MATLAB 7.13 (R2011b)
Other requirements to compile the mex file: mex ordstatfilt2.c
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
28 Jun 2013 Giosue' Lo Bosco

It works

16 Jun 2013 Fabio Bellavia

Jenny, change the two occurrences of calloc with mxCalloc in ordstatfilt2.c, rebuild the mex file and try again. I've uploaded the fixed (I hope) version with an usage example demo. This will be available as soon as matlab administrator will approve the submission, so check the file in the next days.

Comment only
13 Jun 2013 Jenny

Jenny (view profile)

MATLAB crashes any time I try to use it.

14 May 2012 1.3

2nd revision: removed some comment typos

17 Jun 2013 1.4

fix crash on newer matlab version
add usage demo

27 Jun 2013 1.6

added support to build the mex file with microsoft visual studio (thanks to Giosue' Lo Bosco)

Contact us