All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----com.ibm.imageprocessing.ImageProcessing | +----com.ibm.imageprocessing.LowPassFilter
ImageProcessing
abstract class and provides the Lowpass Filtering facility.
It is used for removing high frequency signals (such as noise in an image)
and it has the effect of smoothing the original image.
This class provides the concrete implementation of the
startProcessing
method in its base class. In this method, the
lowpass filtering of the original image is done and processing events are
fired to indicate the status of processing the image.
This class uses one extended java.awt.image.ImageFilter
class
for filtering operation. This extended filter is available by the
getImageFilter
method, which can be used in the context of
the producer/filter/consumer paradigm and
java.awt.image.FilteredImageSource
can be used to take the
advantage of it.
For example:
java.awt.Canvas c = new java.awt.Canvas(); LowPassFilter lpf = new LowPassFilter(); java.awt.ImageFilter filter = lpf.getImageFilter(); java.awt.Image image = Toolkit.getDefaultToolkit(). getImage("c:\\apple.gif"); ..... // use java.awt.MediaTracker or any other technique to load the image .... FilteredImageSource producer = new FilteredImageSource(image.getSource(), filter); java.awt.Image processedImage = c.createImage(producer);There is one more way to do the filtering operation. This will be particularly useful if this class is used as a bean in an IDE and is wired to other beans to do the filtering.
LowPassFilter lpf = new LowPassFilter(); // ifFetchArgumentsEvent
is used for setting the input image // or any control property,autoAction
property should be set to false. // otherwise there can be an infinite loop. lpf.triggerAction(); // since the triggerAction method firesFetchArgumentsEvent
, // on receiving this event the input image for this bean is set using //setInputImage
method of this bean. When the processing // is over,the processed image can be retrieved usinggetResult
// method. java.awt.Image processedImage = lpf.getResult();
public boolean NOTIFY_USER
public LowPassFilter()
public Image getResult()
public void setInputImage(Image inputImage)
processing
flag is true , this method returns without setting
the input image. If the processing
flag is false, this method sets
the input image and calls evaluate
if autoAction
is set to true. If the input argument is null and debug
flag is
true, IllegalArgumentException
will be thrown else the null value
will be set as the input argument and no exception will be thrown.
public ImageFilter getImageFilter()
java.awt.image.ImageFilter
and can be used
as the second argument of the constructor of the
java.awt.image.FilteredImageSource
class. This method is
provided so that this class can also be used in the context of the
producer/filter/consumer paradigm. This method also facilitates the
use of beans as simple classes (instead of wiring them in IDEs).
public synchronized void addImageProcessedListener(ImageProcessedListener listener)
public synchronized void removeImageProcessedListener(ImageProcessedListener listener)
public synchronized void addProcessingListener(ProcessingListener listener)
public synchronized void removeProcessingListener(ProcessingListener listener)
public synchronized void addProcessingErrorListener(ProcessingErrorListener listener)
public synchronized void removeProcessingErrorListener(ProcessingErrorListener listener)
protected void startProcessing()
processingStarted
event initially.Then it waits for the
image to be loaded. If the image has been successfully loaded
(meaning that no ProcessingErrorEvent
event is fired), the image
is filtered and the processed image is stored as a result.
If there is any error in processing(which includes grabbing pixels for result image),
it fires the ProcessingErrorEvent
event and returns.
If the processing is successfully completed, it fires the processingOver
and
ImageProcessedEvent
events. The old result is also stored. It then
compares the new result with the old result. If they are different,
the PropertyChangeEvent
event is fired. If the debug
flag
is true and inputImage
is null, NullPointerException
will be thrown. If the debug
flag is false and inputImage
is null, the result will be set to null and all the required events will be
thrown.
All Packages Class Hierarchy This Package Previous Next Index