Image 2
description
Transcript of Image 2
Image 2
Subject : T0934 / Multimedia Programming FoundationSession : 5Tahun : 2009Versi : 1/0
Bina Nusantara
Learning Outcomes
In the end of this session, students must be able to: – Understand the basic principal
of image transformation and enhancement
– Apply correct Java syntax to transform, enhance, and display an image
Course Outlines
• Digital Image Definition• Image Transformation• Image Enhancement• Java 2D API
Bina Nusantara
Digital Image Definition
• Image array of pixel Z(x,y)
Bina Nusantara
N
M
Z
X = width (0 – N)Y = height (0 – M) Z = pixel values
X = width (0 – N)Y = height (0 – M) Z = pixel values
X
Y
0
Digital Image Definition
• Image Z(x,y)• Z refers to RGB values or brightness
Bina Nusantara
Image Transform in Java
• drawImage– draw and scale an image
• ConvolveOp – blur or sharpen an image
• AffineTransformOp – transform an image
• Graphics2D.setClip – crop an image
Bina Nusantara
Image Enhancement in Java
•LookupOp– remap pixel colors (ex : a negative
image)
•RescaleOp – lighten/darken or reduce/increase
opacity of the image
Bina Nusantara
drawImage
Bina Nusantara
This is an example to draw image with Java2D
Image Transformation
newZ (x,y) = F(Z(x,y))= result of a Function
based on originalZ(x,y)
Horizontal Flipping x’ = N – xy’ = y
Bina Nusantara
Image Transformation
• Vertical Flippingx’ = xy’= M - y
Bina Nusantara
Image Transformation
• Rotation
Bina Nusantara
x' cos a -sin a 0 x y' = sin a cos a 0 y z' 0 0 1 Z
a
Matrix / KernelMatrix / Kernel
Image Rotation
• The basic algorithm is not used in practice– contains unwanted gaps or holes usually requires a greater
number of pixels than the source to properly display the rotation
• Therefore, interpolation is used to solve this problemBina Nusantara
Gaps/holesGaps/holes
Image Interpolation
Bina Nusantara
Interpolation
InterpolationInterpolation
using known data to estimate values at
unknown points.
using known data to estimate values at
unknown points.
Image Transformation
• Cropping
• Scale• Shear
Bina Nusantara
AffineTransformOp
Bina Nusantara
Rotate
Full codes are downloadable in Additional Material
AffineTransformOp
Bina Nusantara
Shear
Full codes are downloadable in Additional Material
AffineTransformOp
Bina Nusantara
Scale
Full codes are downloadable in Additional Material
AffineTransformOp
Bina Nusantara
Translate
Full codes are downloadable in Additional Material
Scale
Bina Nusantara
x’
y’
1
sx 0 0
0 sy 0
0 0 1
x
y
1
= *
RescaleOp
Bina Nusantara
Rescaling
Full codes are downloadable in Additional Material
Shear
Bina Nusantara
x’
y’
1
1 h 0
0 1 0
0 0 1
x
y
1
= *
Image Enhancement
Convolution • an operation in which the final pixel is the weighted sum of
the neighboring pixels• Use matrix/kernel as well convolution kernel / linear filter
Bina Nusantara
Convolution
• Blurring
Bina Nusantara
1 2 12 4 21 2 1
XYZ
Note : This is only an example of many blur kernel variations
Convolution
• Sharpening
Bina Nusantara
-1 -1 -1-1 9 -1-1 -1 -1
XYZ
Note : This is only an example of many sharpen kernel variations
Convolution
• Edge Detection
Bina Nusantara
-1 -1 -1-1 8 -1-1 -1 -1
XYZ
Note : This is only an example of many edge detection kernel variations
ConvolveOp
Bina Nusantara
Blur Full codes are downloadable in Additional Material
ConvolveOp
Bina Nusantara
Sharpen Full codes are downloadable in Additional Material
ConvolveOp
Bina Nusantara
Edge Full codes are downloadable in Additional Material
Image Enhancement
• Brighten/Darken
• Opacity
Bina Nusantara
Brighten Darken
Opacity 80% Opacity 50%
Graphics2D.setClip
Bina Nusantara
setClip is used to clip a portion of images to make a new image
LookupOp
Bina Nusantara
Invert Color
Full codes are downloadable in Additional Material
References
• Image Processing with Java 2D. 2008. http://www.javaworld.com/javaworld/jw-09-1998/jw-09-media.html?page=3
• Image Processing and Enhancement. 1999. http://java.sun.com/j2se/1.3/docs/guide/2d/spec/j2d-image.fm8.html
• Image Processing Fundamentals. 2009. http://www.ph.tn.tudelft.nl/Courses/FIP/noframes/fip.html
• Basic Concepts in Digital Image Processing. 2004. http://micro.magnet.fsu.edu/primer/digitalimaging/javaindex.html
• The Digital Darkroom. 2003. http://www.spinroot.com/pico/a3.pdf• Transforming Shapes, Text, and Images. 2008.
http://java.sun.com/docs/books/tutorial/2d/advanced/transforming.html• Digital Image Interpolation. 2009.
http://www.cambridgeincolour.com/tutorials/image-interpolation.htm• Image Convolution. 2009. http://www.eas.asu.edu/~karam/2dconvolution/• Image Filtering with GLSL - Convolution Kernels. 2009.
http://www.ozone3d.net/tutorials/image_filtering.php• Fundamentals of Image Processing. 2009.
http://www.cs.dartmouth.edu/~farid/tutorials/fip.pdf
Bina Nusantara