Java and Image Manipulation
Document Sample


Java and Image Manipulation
February 18, 2008
Outline
1 JAI
2 Image Manipulation
3 Questions?
2 Monday, January 21, 2008
Java Image Processing
Old and Busted:
• Java AWT
• Java2D
New Hotness:
• JAI
3 Monday, January 21, 2008
What is JAI?
• Java Advanced Imaging
• Image IO
• Advanced Image Processing API
4 Monday, January 21, 2008
First JAI program
public class HelloJAI {
public static void main(String args[]) {
ParameterBlock pb = new ParameterBlock();
pb.add(args[0]);
PlanarImage img = JAI.create(“fileload”, pb, null);
// ta da
}
}
5 Monday, January 21, 2008
First JAI program
ParameterBlock
• Groups arguments
• Appends to the end
• ParameterBlockJAI
6 Monday, January 21, 2008
First JAI program
JAI.create(String, ParameterBlock, ?)
• “A convenience class for instantiating operations.”
• Basically how JAI operations are executed.
• Our example performed the “fileload” operation.
7 Monday, January 21, 2008
First JAI program
RenderingHints
• Just what it sounds like: Hints for rendering
» Layout
» Border
» Interpolation
» Rendering Quality
» others...
8 Monday, January 21, 2008
Second JAI Program
public class HelloAgainJAI {
public static void main(String args[]) {
PlanarImage img = ....;
ParameterBlock pb = new ParameterBlock();
pb.addSource(img)
.add(10.0f)
.add(0.75f);
PlanarImage scaledImg = JAI.create(“scale”, pb);
// ta da again
}
}9 Monday, January 21, 2008
Gotchas
• RenderingHints
• “fileload” vs “stream”
• Lazy Evaluation
10 Monday, January 21, 2008
2 Image Manipulation
11 Monday, January 21, 2008
Morphology
Dilation
Erosion
12 Monday, January 21, 2008
Morphology
• Opening
13 Monday, January 21, 2008
Morphology
• Closing
14 Monday, January 21, 2008
Morphology
• Thinning
15 Monday, January 21, 2008
Morphology
How do we do all this?
16 Monday, January 21, 2008
Morphology
• Structuring element
• Can be any be any shape
• Defines what pixels of an image to keep
• “Slid” around an image
17 Monday, January 21, 2008
Morphology
• Assume a 3x3 square element
• Performing an erosion
18 Monday, January 21, 2008
Morphology
You supply the structuring element,
JAI provides the computation.
19 Monday, January 21, 2008
Morphology
float[] elem = {1, 1, 1, 1, 1, 1, 1, 1, 1};
KernelJAI kernel = new KernelJAI(3, 3, 1, 1, elem);
ParameterBlock pb = new ParameterBlock();
pb.addSource(img).add(kernel);
RenderingHints rh = new RenderingHints(
JAI.KEY_BORDER_EXTENDER,
BorderExtender.createInstance(BorderExtender.BORDER_REFLECT));
PlanarImage erodeImg = JAI.create(“erode”, pb,
rh);
20 Monday, January 21, 2008
Feature Detection
• Edge Detection
• Canny
• Sobel
• Roberts Cross
21 Monday, January 21, 2008
Digital Filters
• Filters and Smoothing
• Mean Filtering
• Median Filtering
• Gaussian Blurring
22 Monday, January 21, 2008
Feature Detection / Digital Filters
Again, how do we do this?
23 Monday, January 21, 2008
Feature Detection / Digital Filters
• Convolution
• Structuring element not just 1/0
• “Slid” across the image as well
• Sum of products
24 Monday, January 21, 2008
Feature Extraction / Digital Filters
25 Monday, January 21, 2008
Feature Extraction / Digital Filters
Once again, the JAI abides.
PlanarImage img = JAI.create(“convolve”, pb, rh);
26 Monday, January 21, 2008
3 Questions?
27 Monday, January 21, 2008
www.PlatinumSolutions.com
Get documents about "