/*
 * Image/J Plugins
 * Copyright (C) 2002-2008 Jarek Sacha
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Latest release available at http://sourceforge.net/projects/ij-plugins/
 *
 */
package net.sf.ij_plugins.filters;

import ij.IJ;
import ij.process.ByteProcessor;
import ij.process.ColorProcessor;
import ij.process.FloatProcessor;
import ij.process.ImageProcessor;
import net.sf.ij_plugins.color.ColorProcessorUtils;

/**
 * Helper for calling fast filter algorithms that match type of ImageProcessor.
 *
 * @author Jarek Sacha
 * @since Oct 23, 2008 10:01:46 PM
 */
public final class FastMedian {
    public static ImageProcessor process(final ImageProcessor ip, final int filterSize) {

        final ImageProcessor dest;
        if (ip instanceof ByteProcessor) {
            dest = process((ByteProcessor) ip, filterSize);
        } else if (ip instanceof ColorProcessor) {
            final ByteProcessor[] srcBps = ColorProcessorUtils.splitRGB((ColorProcessor) ip);
            for (int i = 0; i < srcBps.length; i++) {
                srcBps[i] = process(srcBps[i], filterSize);
            }
            dest = ColorProcessorUtils.mergeRGB(srcBps);
        } else {
            final FloatProcessor src = (FloatProcessor) (ip instanceof FloatProcessor
                    ? ip
                    : ip.convertToFloat());

            final RunningFilter filter
                    = new RunningFilter(new RunningMedianOperator(), filterSize, filterSize);

            // Set progress bar
            if (IJ.getInstance() != null) {
                filter.setProgressBar(IJ.getInstance().getProgressBar());
            }

            // Perform filtering
            dest = filter.run(src);
        }

        return dest;
    }

    private static ByteProcessor process(final ByteProcessor src, final int filterSize) {
        final FastMedianUInt8 filter = new FastMedianUInt8();

        // Set progress bar
        if (IJ.getInstance() != null) {
            filter.setProgressBar(IJ.getInstance().getProgressBar());
        }
        return filter.run(src, filterSize, filterSize);
    }
}

@@ -41,18 +41,18 @@
  2002-20
-08
+11
  Jarek S
@@ -57,16 +57,76 @@
  Sacha%0D%0A
+ * Author's email: jsacha at users dot sourceforge dot net%0D%0A
  *%0D%0A * T
@@ -950,20 +950,16 @@
 ugins/%0D%0A
- *%0D%0A
  */%0D%0Apac
@@ -1202,16 +1202,18 @@
 ils;%0D%0A%0D%0A
+%0D%0A
 /**%0D%0A * 
@@ -1236,16 +1236,23 @@
 ng fast 
+median 
 filter a
@@ -1264,145 +1264,814 @@
 thms
- that match type of ImageProcessor.%0D%0A *%0D%0A * @author Jarek Sacha%0D%0A * @since Oct 23, 2008 10:01:46 PM%0D%0A */%0D%0Apublic final class FastMedian %7B
+.%0D%0A * It will call an implementation that best matches input Image %7B@code ip%7D.%0D%0A * %3Cp/%3E%0D%0A * Sample usa of a 7x7 median filter:%0D%0A * %3Cpre%3E%0D%0A *   ColorProcessor src = ...%0D%0A *   ColorProcessor dest = (ColorProcessor) FastMedian.process(src, 7);%0D%0A * %3C/pre%3E%0D%0A *%0D%0A * @author Jarek Sacha%0D%0A * @since Oct 23, 2008 10:01:46 PM%0D%0A */%0D%0Apublic final class FastMedian %7B%0D%0A%0D%0A    /**%0D%0A     * Apply median filter to input image %7B@code ip%7D.%0D%0A     * For color images (%7B@link ColorProcessor%7D) it will process each color band (R,G,B) independently.%0D%0A     *%0D%0A     * @param ip         input image.%0D%0A     * @param filterSize filter size (window size is filterSize x filterSize)%0D%0A     * @return median filtered input image. The type is the same sa input image,%0D%0A     *         so for ColorProcessor it will be ColorProcessor.%0D%0A     */
 %0D%0A  
@@ -3234,24 +3234,26 @@
 ;%0D%0A    %7D%0D%0A%0D%0A
+%0D%0A
     private 

Add more javadoc.