============================== EXERCISE: reduce an image > Picture p = new Picture( "/Users/wallingf/Desktop/ew-small.jpg" ); > p.show(); > p Picture, filename /Users/wallingf/Desktop/ew-small.jpg height 72 width 55 * how can we make an image *larger*? - one simple approach: repeat pixels * write a method to do it... > p = p.scaleUp(); > p.show(); > p.write( "/Users/wallingf/Desktop/ew-bigger.jpg" ); > p = new Picture( "/Users/wallingf/Desktop/mountain.jpg" ); > p.show(); > p = p.scaleUp(); > p.show(); > p.write( "/Users/wallingf/Desktop/mountain-bigger.jpg" ); * how can we do this better? - one simple approach: fill in new slots with "average" pixels * at home: write a method to do it... ============================== EXERCISE: what does mysteryMethod() do? ============================== TASK: change color of my shirt > p = new Picture( "/Users/wallingf/Desktop/wallingf-250x328.jpg" ); > p.explore(); * try (79,246) - 175/138/156 * I'd like a Kelly green: > ColorChooser.pickAColor(); * 0/102/0 * try to bring color close to this > Picture p = new Picture( "/Users/wallingf/Desktop/wallingf-250x328.jpg" ); > p.explore(); > p.mysteryMethod(); > p.show(); * this makes the image greener - but I want to change only the shirt's color! - what is the color? * use explorer to find ( 163, 124, 143 ) * try to change any pixel with this color > p.explore() - actually, *close* to this color - aPixel.colorDistance() ============================== SLIDES: Guarded Action ============================== TASK: remove camera glare from glasses > p = new Picture( "/Users/wallingf/Desktop/wallingf-250x328.jpg" ); > p.explore(); * (200,179,158) @ ( 97,92) -- glare * (182,122, 70) @ (142,93) -- flesh - look in small region (92,87)-(103,96) and replace glare... * see code > Picture p = new Picture( "/Users/wallingf/Desktop/wallingf-250x328.jpg" ); > p.show(); > p.eliminateGlareInGlasses(); > p.repaint(); * problem: one pixel was so white, it failed the test! * try a large epsilon... 75, 100? * working with media requires experimentation ============================== TASK: remove red eye * the text's removeRedEye method does just this - but takes as arguments the range and the color - still hardcodes color to replace (red) and distance (167) > Picture p = new Picture( "/Users/wallingf/Desktop/sarah-headshot.jpg" ); > p.show(); > p.explore(); * on Sarah: find range (110,247)->(120,260) and use black > import java.awt.Color; > p.removeRedeye( 110, 247, 120, 260, Color.black ); > p.repaint(); * problem? "pink eye" * solution? make the distance a parameter, too > p.removeRedeye( 110, 247, 120, 260, 200, Color.black ); > p.repaint(); ============================== EXERCISE: how to remove only red *eye*? > p.removeRedeye( 0, 0, p.getWidth(), p.getHeight(), 200, Color.black ); > p.repaint(); ============================== TASK: edge detection * use explorer to walk boundaries on the mountain * aPixel.getAverage() > p = new Picture( "/Users/wallingf/Desktop/mountain.jpg" ); > p.detectEdges( 25 ); > p.show(); > p = new Picture( "/Users/wallingf/Desktop/wallingf-250x328.jpg" ); > p.detectEdges( 25 ); > p.repaint(); > p = new Picture( "/Users/wallingf/Desktop/wallingf-250x328.jpg" ); > p.detectEdges( 15 ); > p.repaint(); > p = new Picture( "/Users/wallingf/Desktop/sarah-headshot.jpg" ); > p.detectEdges( 15 ); > p.repaint(); > p = new Picture( "/Users/wallingf/Desktop/sarah-headshot.jpg" ); > p.detectEdges( 10 ); > p.repaint(); > p = new Picture( "/Users/wallingf/Desktop/sarah-headshot.jpg" ); > p.detectEdges( 5 ); > p.repaint(); ============================== SLIDES: Alternative Action, Computer Vision