4.25

4.2 | 4 ratings Rate this file 78 Downloads (last 30 days) File Size: 28.67 KB File ID: #24705

Min/Max filter

by Bruno Luong

 

12 Jul 2009 (Updated 01 Dec 2009)

Multidimensional non-linear min/max filtering

| Watch this File

File Information
Description

The filter computes the minima and/or maxima of an array over sliding window with a given size.

Multidimensional array is fully supported: running filter in 1D, 2D filter for image processing applications (erosion/dilatation), 3D and more.

This package has been implemented with a special care on the running speed: the MEX engine uses an algorithms that requires no more than three (3) comparisons per element and per dimension in all configurations.

All numerical and logical class arrays are supported.

Contributor (beside author) is Vaclav Potesil

Acknowledgements
This submission has inspired the following:
Free-knot spline approximation
MATLAB release MATLAB 7.8 (R2009a)
Other requirements MEX correctly setup NO image processing is required Download a tiff file for Lena's demo
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
24 Mar 2010 Tobias

Nice Max-Filter. Works faster than implementation of Frederico D'Almeida and seems to be correct.

03 Oct 2010 Bruno Luong

I copy the question from Michael Teo: Does it handle NaN data?

<QUOTE>
ePeriod = 3;
eData = [ 5;1;3;NaN;8;2;3;NaN;1;9 ];
minmaxfilt(eData, ePeriod, 'max', 'valid');

Actual output:
[5;3;3;NaN;8;3;3]

If we take NaN as a empty data, the expected output is:
[5;3;8;8;8;3;3]
</ENDQUOTE>

The answer is "no". The work around id to replace NaN by -Inf for running max and +Inf for running min.

 eData(isnan(eData))=-inf
 minmaxfilt(eData, ePeriod, 'max', 'valid')

03 Oct 2010 Michael Teo

Thanks for sharing, its make sense and it solved my problem. :)

06 Oct 2011 shi  
20 Oct 2011 Qiao Liyong  
Please login to add a comment or rating.
Updates
13 Jul 2009

Correct a bug that causes crash on 64-bit plateform
Additional memory check in one MEX function
Friendly matlab gateway for 1D min/max filtering

20 Sep 2009

New feature: Possibly to output corresponding indexes arrays (suggested by a user) + slight improvement of the Lemire's engine.

21 Sep 2009

Correct BUG of cropping the index array when shape is SAME

21 Sep 2009

Acknowledgment

22 Sep 2009

Cleaner algorithm for same shape filtering

26 Sep 2009

description

01 Dec 2009

Correct a small bug when "WIN" is a scalar and input array is vector (error wrongly issued)

Tag Activity for this File
Tag Applied By Date/Time
image processing Bruno Luong 13 Jul 2009 12:15:27
minmax filter Bruno Luong 13 Jul 2009 12:15:27
filtering Bruno Luong 13 Jul 2009 12:15:27
kramerbruckner Bruno Luong 13 Jul 2009 12:15:27
erosion Bruno Luong 13 Jul 2009 12:15:27
running min Bruno Luong 13 Jul 2009 12:15:27
pattern recognition Bruno Luong 13 Jul 2009 12:15:27
running max Bruno Luong 13 Jul 2009 12:15:27
dilatation Bruno Luong 13 Jul 2009 12:15:27
dilatation jurmucioz Tsiou 13 Oct 2009 18:32:56

Contact us at files@mathworks.com