Package com.jhlabs.image
Class MotionDetectorFilter
- java.lang.Object
- 
- com.jhlabs.image.AbstractBufferedImageOp
- 
- com.jhlabs.image.MotionDetectorFilter
 
 
- 
- All Implemented Interfaces:
- java.awt.image.BufferedImageOp,- java.lang.Cloneable
 
 public class MotionDetectorFilter extends AbstractBufferedImageOp A motion detector image filter. This filter compares each image to be filtered against the previously provided image to be filtered. If enough of the pixels differ by enough, then it modifies the image to be filtered by adding a small red circle at the center of gravity of the pixels that differ by enough. The parameters of the filter are:- PixelThreshold: Intensity threshold whereby a pixel is deemed to different (an int 0 - 255, with default 25).
- AreaThreshold: The percentage threshold of image that has different pixels for motion to be detected (a double 0-100, with default 0.2).
- ModifyImage: If true (the default), the modify the provided image with a visual indication of the location and amount of motion.
 - Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Bartosz Firyn (SarXos) and Edward A. Lee
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Yellow (eal)
 
- 
- 
Constructor SummaryConstructors Constructor Description MotionDetectorFilter()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.image.BufferedImagefilter(java.awt.image.BufferedImage source, java.awt.image.BufferedImage destination)Filter the source image, and if motion is detected, place a red circle at the center of gravity of the motion.doublegetAreaThreshold()Get the percentage fraction of detected motion area threshold above which it is classified as "moved".java.awt.PointgetCOG()Return center of gravity of motion detected by the most recent invocation of filter(), or null if no motion was detected.booleangetModifyImage()Return whether the filter will modify the provided image with a visual indication of the amount and location of the motion.doublegetMotionArea()Return the motion strength (0 = no motion, 100 = full image covered by motion).intgetPixelThreshold()Get the pixel intensity difference threshold above which pixel is classified as "moved".booleanisMotion()Return whether motion was detected in the last filter operation.voidsetAreaThreshold(double threshold)Set the percentage fraction of detected motion area threshold above which it is classified as "moved".voidsetModifyImage(boolean modify)Specify whether to modify the image with a visual indication of the amount and location of the motion.voidsetPixelThreshold(int threshold)Set the pixel intensity difference threshold above which pixel is classified as "moved".java.lang.StringtoString()Return a string description of the filter.- 
Methods inherited from class com.jhlabs.image.AbstractBufferedImageOpclone, createCompatibleDestImage, getBounds2D, getPoint2D, getRenderingHints, getRGB, setRGB, stringToColor
 
- 
 
- 
- 
- 
Method Detail- 
filterpublic java.awt.image.BufferedImage filter(java.awt.image.BufferedImage source, java.awt.image.BufferedImage destination)Filter the source image, and if motion is detected, place a red circle at the center of gravity of the motion. If the destination argument is null, then the red circle is added directly to the source, and the source is returned. Otherwise, the red circle is added to the destination image.- Parameters:
- source- The source image, on which motion is detected.
- destination- The destination image, on which the red circle is added, or null to specify to add the circle to the source image.
 
 - 
getAreaThresholdpublic double getAreaThreshold() Get the percentage fraction of detected motion area threshold above which it is classified as "moved". Minimum value for this is 0 and maximum is 100, which corresponds to full image covered by spontaneous motion.- Returns:
- The percentage of image area.
- See Also:
- setAreaThreshold(double)
 
 - 
getCOGpublic java.awt.Point getCOG() Return center of gravity of motion detected by the most recent invocation of filter(), or null if no motion was detected.- Returns:
- The center of gravity of motion (in pixels).
 
 - 
getModifyImagepublic boolean getModifyImage() Return whether the filter will modify the provided image with a visual indication of the amount and location of the motion.- Returns:
- True if the image will be modified (the default).
 
 - 
getMotionAreapublic double getMotionArea() Return the motion strength (0 = no motion, 100 = full image covered by motion).- Returns:
- The motion area percentage.
 
 - 
getPixelThresholdpublic int getPixelThreshold() Get the pixel intensity difference threshold above which pixel is classified as "moved". The minimum value is 0 and maximum is 255. Default value is 10. This value is equal for all RGB components difference.- Returns:
- The pixel intensity difference threshold.
- See Also:
- setPixelThreshold(int)
 
 - 
isMotionpublic boolean isMotion() Return whether motion was detected in the last filter operation.- Returns:
- Whether motion was detected.
 
 - 
setAreaThresholdpublic void setAreaThreshold(double threshold) Set the percentage fraction of detected motion area threshold above which it is classified as "moved". The minimum value for this is 0 and maximum is 100, which corresponds to full image covered by spontaneous motion.- Parameters:
- threshold- The percentage of image area.
- See Also:
- getAreaThreshold()
 
 - 
setModifyImagepublic void setModifyImage(boolean modify) Specify whether to modify the image with a visual indication of the amount and location of the motion.- Parameters:
- modify- True to modify the image.
- See Also:
- getModifyImage()
 
 - 
setPixelThresholdpublic void setPixelThreshold(int threshold) Set the pixel intensity difference threshold above which pixel is classified as "moved". The minimum value is 0 and maximum is 255. Default value is 10. This value is equal for all RGB components difference.- Parameters:
- threshold- The pixel intensity difference threshold.
- See Also:
- getPixelThreshold()
 
 - 
toStringpublic java.lang.String toString() Return a string description of the filter.- Overrides:
- toStringin class- java.lang.Object
- Returns:
- The string "MotionDetectorFilter".
 
 
- 
 
-