import Myro.*; import java.awt.*; /** * Find the blues in an image and change them to red * * @author (your name) */ public class FindBlue { // declare the Scribbler object private Scribbler robot; /* // TODO: Define the following constants based on a color of your choosing for part 3 final int REF_R = ; final int REF_G = ; final int REF_B = ; final int THRESHOLD = ; */ /** * Determine if a color is a shade of blue: For part 1 * * @param c A color * @return true if c is a shade of blue */ private boolean isBlue( Color c ) { // TODO: implement this method return false; } //For part 1 public void findBlue() { robot = new Scribbler("com3"); MyroImage anImage = robot.takePicture(Scribbler.IMAGE_COLOR); //TODO: go through all pictures in the image //if a pixel is Blue, set it to the color red } //for part 3 private boolean isColor( Color c ) { // TODO: calculate the difference between c and the reference color // TODO: calculate the distance between c and the reference color // TODO: return true if the distance is <= THRESHOLD, return false otherwise return false; } //for part 3 private MyroImage calcBlob( MyroImage image ) { MyroImage blobImage = new MyroGrayImage( image.getWidth(), image.getHeight() ); // TODO: Process every pixel of image. If the color of pixel p meets the color specification // of isColor, set the corresponding pixel in blobImage to white; otherwise set the corresponding // pixel in blobImage to black. // return blobImage return blobImage; } //for part 3 public void blobScribbler() { MyroImage image; MyroImage blob; // open a connection to the Scribbler robot = new Scribbler("COM40"); // execute until the user presses a key while( !MyroListener.isKeyPressed() ) { // TODO: Take a picture, put it in variable image,then display it // TODO: Invole calcBlob, passing it image and putting the return value in blob. Display // blob in a window titled "blob". } // close the robot robot.close(); } }