Java Reference
In-Depth Information
Figure 11.3 Edge
detection convolution
applied on the left image
produces the image on
the right.
enhances the edge regions but does not zero out the uniform regions, thus giving
a sharpening effect.
To create an edge detection instance of the ConvoleOp class, we can use code
like the following:
float edge - mat ={0.0, -1.0, 0.0,
-1.0, 4.0, -1.0,
0.0, -1.0, 0.0};
ConvoleOp edge - finder - op =
new ConvoleOp (new Kernel(3,3,edge - mat),
ConvoleOp.EDGE - NO - OP, null);
(The last parameter is for an optional RenderingHints object that you can
use to adjust the color conversion.) We can then apply this convolution tool to an
image with
BufferedImage edge - img = edge - finder - op.filter (an - image,
null);
The ConvoleOp class requires that the source and destination objects be differ-
ent BufferedImage objects. Figure 11.3 shows an example of applying this
convolution to an image.
11.9.2 Affine transforms
The affine transform filters map 2D structures in one space to another space
while maintaining the straight lines and parallelism in the original image. (We
discussed these transforms in Section 6.8 with regard to Java 2D drawing.)
The operations include translation, scaling, flipping, rotation, and shearing. An
AffineTransformOp object uses an instance of AffineTransform to apply
the transform to a source image to create a new destination image (which must
be different BufferedImage objects).
Search WWH ::




Custom Search