ij.plugin.filter
Class BackgroundSubtracter

java.lang.Object
  extended by ij.plugin.filter.BackgroundSubtracter
All Implemented Interfaces:
PlugInFilter

public class BackgroundSubtracter
extends java.lang.Object
implements PlugInFilter

Implements ImageJ's Subtract Background command. Based on the NIH Image Pascal version by Michael Castle and Janice Keller of the University of Michigan Mental Health Research Institute. Rolling ball algorithm inspired by Stanley Sternberg's article, "Biomedical Image Processing", IEEE Computer, January 1983.


Field Summary
 
Fields inherited from interface ij.plugin.filter.PlugInFilter
CONVERT_TO_FLOAT, DOES_16, DOES_32, DOES_8C, DOES_8G, DOES_ALL, DOES_RGB, DOES_STACKS, DONE, FINAL_PROCESSING, NO_CHANGES, NO_IMAGE_REQUIRED, NO_UNDO, PARALLELIZE_STACKS, ROI_REQUIRED, SNAPSHOT, STACK_REQUIRED, SUPPORTS_MASKING
 
Constructor Summary
BackgroundSubtracter()
           
 
Method Summary
(package private)  void extrapolateBackground(ImageProcessor background, RollingBall ball)
          Uses linear extrapolation to find pixel values on the top, left, right, and bottom edges of the background.
(package private)  void extrapolateBackground16(ImageProcessor background, RollingBall ball)
          This is a 16-bit version of the extrapolateBackground() method.
(package private)  void interpolateBackground(ImageProcessor background, RollingBall ball)
          Uses bilinear interpolation to find the points in the full-scale background given the points from the shrunken image background.
(package private)  void interpolateBackground16(ImageProcessor background, RollingBall ball)
          This is a 16-bit version of the interpolateBackground(0 method.
(package private)  ImageProcessor rollBall(RollingBall ball, ImageProcessor image, ImageProcessor smallImage)
          'Rolls' a filtering object over a (shrunken) image in order to find the image's smooth continuous background.
(package private)  ImageProcessor rollBall16(RollingBall ball, ImageProcessor image, ImageProcessor smallImage)
          This is a 16-bit version of the rollBall() method.
 void run(ImageProcessor ip)
          Filters use this method to process the image.
 int setup(java.lang.String arg, ImagePlus imp)
          This method is called once when the filter is loaded.
 void showDialog()
           
(package private)  ImageProcessor shrinkImage(ImageProcessor ip, int shrinkfactor)
          Creates a lower resolution image for ball-rolling.
 void subtractBackround(ImageProcessor ip, int ballRadius)
          Implements a rolling-ball algorithm for the removal of smooth continuous background from a two-dimensional gel image.
 void subtractRGBBackround(ColorProcessor ip, int ballRadius)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BackgroundSubtracter

public BackgroundSubtracter()
Method Detail

setup

public int setup(java.lang.String arg,
                 ImagePlus imp)
Description copied from interface: PlugInFilter
This method is called once when the filter is loaded. 'arg', which may be blank, is the argument specified for this plugin in IJ_Props.txt or in the plugins.config file of a jar archive containing the plugin. 'imp' is the currently active image. This method should return a flag word that specifies the filters capabilities.

For Plugin-filters specifying the FINAL_PROCESSING flag, the setup method will be called again, this time with arg = "final" after all other processing is done.

Specified by:
setup in interface PlugInFilter

run

public void run(ImageProcessor ip)
Description copied from interface: PlugInFilter
Filters use this method to process the image. If the SUPPORTS_STACKS flag was set, it is called for each slice in a stack. With CONVERT_TO_FLOAT, the filter is called with the image data converted to a FloatProcessor (3 times per image for RGB images). ImageJ will lock the image before calling this method and unlock it when the filter is finished. For PlugInFilters specifying the NO_IMAGE_REQUIRED flag and not the DONE flag, run(ip) is called once with the argument null.

Specified by:
run in interface PlugInFilter

showDialog

public void showDialog()

subtractRGBBackround

public void subtractRGBBackround(ColorProcessor ip,
                                 int ballRadius)

subtractBackround

public void subtractBackround(ImageProcessor ip,
                              int ballRadius)
Implements a rolling-ball algorithm for the removal of smooth continuous background from a two-dimensional gel image. It rolls the ball (actually a square patch on the top of a sphere) on a low-resolution (by a factor of 'shrinkfactor' times) copy of the original image in order to increase speed with little loss in accuracy. It uses interpolation and extrapolation to blow the shrunk image to full size.


rollBall

ImageProcessor rollBall(RollingBall ball,
                        ImageProcessor image,
                        ImageProcessor smallImage)
'Rolls' a filtering object over a (shrunken) image in order to find the image's smooth continuous background. For the purpose of explaining this algorithm, imagine that the 2D grayscale image has a third (height) dimension defined by the intensity value at every point in the image. The center of the filtering object, a patch from the top of a sphere having radius BallRadius, is moved along each scan line of the image so that the patch is tangent to the image at one or more points with every other point on the patch below the corresponding (x,y) point of the image. Any point either on or below the patch during this process is considered part of the background. Shrinking the image before running this procedure is advised due to the fourth-degree complexity of the algorithm.


shrinkImage

ImageProcessor shrinkImage(ImageProcessor ip,
                           int shrinkfactor)
Creates a lower resolution image for ball-rolling.


interpolateBackground

void interpolateBackground(ImageProcessor background,
                           RollingBall ball)
Uses bilinear interpolation to find the points in the full-scale background given the points from the shrunken image background. Since the shrunken background is found from an image composed of minima (over a sufficiently large mask), it is certain that no point in the full-scale interpolated background has a higher pixel value than the corresponding point in the original image


extrapolateBackground

void extrapolateBackground(ImageProcessor background,
                           RollingBall ball)
Uses linear extrapolation to find pixel values on the top, left, right, and bottom edges of the background. First it finds the top and bottom edge points by extrapolating from the edges of the calculated and interpolated background interior. Then it uses the edge points on the new calculated, interpolated, and extrapolated background to find all of the left and right edge points. If extrapolation yields values below zero or above 255, then they are set to zero and 255 respectively.


rollBall16

ImageProcessor rollBall16(RollingBall ball,
                          ImageProcessor image,
                          ImageProcessor smallImage)
This is a 16-bit version of the rollBall() method.


interpolateBackground16

void interpolateBackground16(ImageProcessor background,
                             RollingBall ball)
This is a 16-bit version of the interpolateBackground(0 method.


extrapolateBackground16

void extrapolateBackground16(ImageProcessor background,
                             RollingBall ball)
This is a 16-bit version of the extrapolateBackground() method.