Image Processing CS177
Announcements Project 5 due next week Next week's recitation will be review for final exam Extra columns on blackboard to show average in projects, labs and exams Sample exam will be posted by Monday
Questions?
Color System RGB : colors are made using combination of Red, Green and Blue Widely used for electronic screens CMYK : subtractive system in which colors are made using combination of Cyan, Magenta, Yellow and Key (Black) Used in printers as the default paper color is white
Color Class It uses RGB model – hence requires mixture of RGB to make final color Color c = new Color(r, g, b); r, g, b is quantity of colors Red, Green and Blue respectively 0<=r, g, b<=255 To get a particular component of a color, use getRed(), getGreen() or getBlue() method
Picture Class Provides a way to deal with .jpg and .png files as a 2D array It creates and saves only .jpg and .png files. Other formats are not acceptable In get(int i, int j) and set(int i, int j, Color c), 'i' is column and 'j' is row number of the pixel
Merge two images of same size Picture picture1 = new Picture( file1 ); Picture picture2 = new Picture( file2 ); int w = picture1.width(); int h = picture1.height(); Picture merged = new Picture(w,h); for( int i = 0; i < w; i++ ) for( int j = 0; j < h; j++ ) { int r = picture1.get(i, j).getRed() + opacity * picture2.get(i, j).getRed() / 100; //same for green and blue //what is wrong here? merged.set(i,j,new Color(r, g, b)); }
Questions