cdox.util.image
Class Sharpen
java.lang.Object
java.util.Observable
cdox.util.image.CorrectorSlider
cdox.util.image.Sharpen
- All Implemented Interfaces:
- javax.swing.event.ChangeListener, java.util.EventListener, ImageCorrector
- public class Sharpen
- extends CorrectorSlider
- implements ImageCorrector
This class sharpens a BufferedImage. It uses a kernel and ConvolOp to do so. To use this
class you can call one of its two constructors. If you've designed your own Jslider
classes you can use the constructor which takes a float-value. You than can use the
setValue(float val) method to set the value to work with. And than call the filter
method to filter the BufferedImage.If value == 0f the original (source-image) will be
returned.
- Version:
- 16 April 2002
- Author:
- Rutger Bezema, Andreas Schmitz
- See Also:
CorrectorSlider
Constructor Summary |
Sharpen(float val)
This constructor creates a new Sharpen Object with its initial-Value set to val. |
Sharpen(java.util.Observer obs,
java.lang.String paneTitle)
This constructor creates a new Sharpen Object, with a JSlider in a JPanel with a
titledBorder set with the name paneTitle. |
Method Summary |
java.awt.image.BufferedImage |
filter(java.awt.image.BufferedImage source,
java.awt.image.BufferedImage dest)
The actual filtering is done in this method defined in ImageCorrector. |
Methods inherited from class java.util.Observable |
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Sharpen
public Sharpen(java.util.Observer obs,
java.lang.String paneTitle)
- This constructor creates a new Sharpen Object, with a JSlider in a JPanel with a
titledBorder set with the name paneTitle. The values of the JSlider are standardly
min=0, max = 6, initValue=0, spacings=1, textatSpacing=1,
graptogrid=true. The Observer is called when the JSlider is moved. This Observer
could be a preview pane or anything else.
- Parameters:
obs
- The Observer to handle the BufferedImage.paneTitle
- the title of the titledBorder of the JPane surrounding the JSlider.- See Also:
CorrectorSlider.CorrectorSlider(Observer, String, int, int, int, int, int, boolean).
Sharpen
public Sharpen(float val)
- This constructor creates a new Sharpen Object with its initial-Value set to val. It
has no JSlider and the value of this class (to work with) should be set by calling
setValue(float val).
- Parameters:
val
- the initial float value.- See Also:
CorrectorSlider.CorrectorSlider(float)
,
CorrectorSlider.setValue(float)
filter
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage source,
java.awt.image.BufferedImage dest)
The actual filtering is done in this method defined in ImageCorrector. It uses a
Kernel and a ConvolveOp to make the BufferedImage look more sharpen for all the four
chanels (Red,Green, Blue, Alpha).
The Kernel is defined as a "3x3"-Matrix of floats with following form:
- 0.0, -1.0, 0.0
- -1.0, 5.0, -1.0
- 0.0, -1.0, 0.0
.
This Kernel is used in a ConvolveOp Object. For each value of "value" *(set by
the JSlider or setValue(float val)) this method first blurs the source image,
and than applies the ConvolveOp to sharpen it. If the blurring not is done, the
image would be irrecognizable for values >1. It causes this method to be very slow
for larger values (>3) though, life's a bitch.
To make sure the source-BufferedImage can be "sharpened" the image is redrawn on
a new BufferedImage which will be filtered. If the destination BufferedImage is
null, a new BufferedImage is returned, if not it must have the same height and width
as the source-BufferedImage. If not a new BufferedImage is returned.
- Specified by:
filter
in interface ImageCorrector
- Parameters:
source
- the BufferedImage to be filtered,dest
- the Destination-BufferedImage with the same height and width as Source,
and which may be null.
- Returns:
- the filtered BufferedImage.
- See Also:
Blur
,
ImageCorrector
,
CorrectorSlider.setValue(float)