320 likes | 514 Views
Image 2. Subject : T0934 / Multimedia Programming Foundation Session : 5 Tahun : 2009 Versi : 1/0. Learning Outcomes. In the end of this session, students must be able to: Understand the basic principal of image transformation and enhancement
E N D
Image 2 Subject : T0934 / Multimedia Programming Foundation Session : 5 Tahun : 2009 Versi : 1/0
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
Digital Image Definition • Image array of pixel Z(x,y) X 0 N Z Y X = width (0 – N) Y = height (0 – M) Z = pixel values M
Digital Image Definition • Image Z(x,y) • Z refers to RGB values or brightness
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
Image Enhancement in Java • LookupOp • remap pixel colors (ex : a negative image) • RescaleOp • lighten/darken or reduce/increase opacity of the image
drawImage 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 – x y’ = y
Image Transformation • Vertical Flipping x’ = x y’= M - y
Image Transformation • Rotation a x' cos a -sin a 0 x y' = sin a cos a 0 y z' 0 0 1 Z Matrix / 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 problem Gaps/holes
Image Interpolation Interpolation Interpolation using known data to estimate values at unknown points.
Image Transformation • Cropping • Scale • Shear
AffineTransformOp Rotate Full codes are downloadable in Additional Material
AffineTransformOp Shear Full codes are downloadable in Additional Material Bina Nusantara
AffineTransformOp Scale Full codes are downloadable in Additional Material Bina Nusantara
AffineTransformOp Translate Full codes are downloadable in Additional Material Bina Nusantara
Scale x’ y’ 1 sx 0 0 0 sy 0 0 0 1 x y 1 = *
RescaleOp Rescaling Full codes are downloadable in Additional Material
Shear 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
Convolution • Blurring Note : This is only an example of many blur kernel variations X Y Z 1 2 1 2 4 2 1 2 1
Convolution • Sharpening Note : This is only an example of many sharpen kernel variations X Y Z -1 -1 -1 -1 9 -1 -1 -1 -1
Convolution • Edge Detection Note : This is only an example of many edge detection kernel variations X Y Z -1 -1 -1 -1 8 -1 -1 -1 -1
ConvolveOp Blur Full codes are downloadable in Additional Material
ConvolveOp Sharpen Full codes are downloadable in Additional Material Bina Nusantara
ConvolveOp Edge Full codes are downloadable in Additional Material Bina Nusantara
Image Enhancement • Brighten/Darken • Opacity Brighten Darken Opacity 80% Opacity 50%
Graphics2D.setClip setClip is used to clip a portion of images to make a new image
LookupOp 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