Title: Image Processing in Java
1Image Processing in Java
2Introduction
- Observer-observable DPs
- Review of HW solution
- Input of values to the system
3Agenda
4Overview
- public int filterRGB (int rgb)
- int red (rgb 0xff0000) gtgt16
- int green (rgb 0xff00) gtgt 8
- int blue rgb 0xff
- int gray (red green blue) / 3
- return (
- 0xff000000
- (gray ltlt 16)
- (gray ltlt 8) gray)
-
5Review of Arrays
public static void print(double a) for
(int i 0 i lt a.length i) for (int j
0 j lt a0.length j) System.out.print(ai
j" ") System.out.println()
6Row-Major
If arrays are row major, then increment the row
more quickly public void print() for
(int j 0 j lt 3 j) for (int i
0 i lt 3 i)
System.out.print(aij" ")
System.out.println()
7Row vs Column Major
8Simulating 2D arrays
public int getPixel(int x, int y) return
pelsywidth x
9Drawing in Java
public void repaint() public void repaint(long
t) public void repaint(int x, int y, int w, int
h) public void repaint(long t, int x, int y, int
w, int h)
10Damage Control
11ImageFrame-a series of methods that ease image
processing
12- public class ImageFrame extends ShortCutFrame
- public short r
- public short g
- public short b
-
- public int width 128
- public int height 128
-
- public ImageFrame(String title)
- public void setImage(Image i)
- public Image getImage()
- public void short2Image()
- public void image2Short()
- public void openGif()
- public void openGif(String fn)
- public static void main(String args)
-
13FilterFrame-Sample
26. public void gray() 27. for (int x0
x lt width x) 28. for (int y0 y lt
height y) 29. rxy (short) 30.
((rxy gxy bxy) /
3) 31. gxy rxy 32.
bxy rxy 33. 34.
short2Image() 35.
14TestPatterns
15SnellWlx
16GrabFrame
- public class GrabFrame extends FilterFrame
- public void grab(Container f)
- public void testPattern()
17TestPattern
18Homogeneous Point Processing
- Every point is treated the same
- Input size of image is same as output size
- Good application of statistics!
19PMF
- Add the total number of pixels of a particular
value - Divide by the total number of pixels
20Rules of Prob.
- Sum of all probs1
- CMF is sum of all values up to a point.
21Histogram Computations
histArray new double256 for (int i0
iltwidth i) for (int j0 j lt height
j) histArrayplaneij 0xFF
22Normalization of PMF
double max 0.0 for(int i0 ilt256
i) if (histArrayi gt max)
max histArrayi // Normalize
for(int i0 ilt256 i) histArrayi
(histArrayi / max)
23The Histogram of the Image
24Summary of Histogram
package gui public class Histogram extends
ClosableFrame public double getPMF()
public double getCMF() public void
printPMF() public void show() public
Histogram(short plane, String title)
public void paint(Graphics g)
25Linear Map and Sample Image
26Negating an Image
27Implementation
for (int y0 y lt height y) rxy
(short) (255 - rxy) gxy
(short) (255 - gxy) bxy
(short) (255 - bxy) short2Image()
28Power law and image processing
29Washed out images can result
301.5 exponentdarkening
31Darkening Image
32Darkening and the Histogram
33Implementing the power xform
public void powImage(double p) for (int x0
x lt width x) for (int y0 y lt height
y) rxy (short)
(255 Math.pow((rxy/255.0),p))
gxy (short) (255
Math.pow((gxy/255.0),p)) bxy
(short) (255
Math.pow((bxy/255.0),p))
short2Image()
34Changing Brightness and Contrast
35Linear eq and histogram
36Brightening and image
37Computing parameters automatically
38UNAHE
39The CMF
40Adaptive Equalization
41Histogram an AUHE
42LUT Implementation
package gui public class TransformTable
public TransformTable(int size) public short
getLut() public void setLut(short lut)
public void print()
43The NegateFrame
44Computing Averages
45Two kinds of methods for altering an image
- The direct methods
- The indirect methods.
- The direct methods employ a mapping function,
- Mapping functions are applied to the color planes.
46Indirect Methods
- The indirect method use statistical properties
- Two Kinds of Indirect Methods
- adaptive and nonadaptive