Posts

Showing posts from July, 2016

Finding A gene in DNA Solution Quiz 1 --Java Programming: Solving Problems with Software

Image
a For The Second Answer Click HERE

Finding A URl on a Page Java Code --Java Programming: Solving Problems with Software

/**  * Write a description of URLFINDER here.  *  * @author (your name)  * @version (a version number or a date)  */ import edu.duke.*; import java.io.*; public class URLFINDER {     public void asd(){         URLResource file = new URLResource("http://www.dukelearntoprogram.com/course2/data/manylinks.html");         for ( String item : file.words() ) {             String itemLower = item.toLowerCase();             int pos = itemLower.indexOf("youtube.com");             if ( pos != -1 ) {                 int beg = item.lastIndexOf("\"", pos);                 int end = item.indexOf("\"", pos + 1);                 System.out.println(item.substring(beg + 1, end));         }     }   } }

Code For finding aProtien string in a DNA --Java Programming: Solving Problems with Software

import edu.duke.*; import java.io.*; public class TagFinder{     public String findProtein(String dna){         int start = dna.indexOf("atg");         int stop = dna.indexOf("tag", start +3);         if (start == -1){             return "no starton protein found";         }                if ((stop-start)%3==0){             return dna.substring(start,stop+3);         }         else{             return"not not a protein because of Divisible factor";         }     }     public void testing()     {         String a = "cccatggggtttaaataataataggagagagagagagagttt";         String ap = "atggggtttaaataataatag";         //String a = "sdafsdfsdatgccctagdsfsdfgsffd";         //String ap = "atgccctag";         //String a = "atgcctag";         //String ap = "";         //String a = "ATGCCCTAG";         //String ap = "ATGCCCTAG";         String result = findProtein(a);         if

Iterables In Java Main Quiz --Java Programming: Solving Problems with Software 1

Image
A For The Second Solution CLICK  HERE

Batch GrayScale Images Practice Quiz Solutions --Java Programming: Solving Problems with Software

Image

Converting Images to Gray Scale And Saving A Copy Of Them(Multiple) -- Java Programming: Solving Problems with Software

import edu.duke.*; import java.io.File; public class GrayScaleConverter {     //started with the image i wanted(inImage)     public ImageResource makeGray(ImageResource inImage){     //I Made a blank image of the same size         ImageResource outImage = new ImageResource(inImage.getWidth(),inImage.getHeight());     //for each pixelin outImage         for(Pixel pixel : outImage.pixels()){     //look at the corresponding pixel in inImage             Pixel inPixel = inImage.getPixel(pixel.getX(),pixel.getY());     //compute inPixel's red + inPixel's blue + inpixel's green     //divide that sum by 3(call it average)     int average = (inPixel.getRed()+inPixel.getGreen()+inPixel.getBlue())/3;     //set pixel's red to average     pixel.setRed(average);     //set pixel's green to average     pixel.setGreen(average);     //set pixel's blur to average     pixel.setBlue(average);     }      return outImage;     }           public void SelectAndConvert(){         Direct

Image Saver --Java Programming: Solving Problems with Software

import edu.duke.*; import java.io.*; public class imageSaver {     public void doSave(){         DirectoryResource dr = new DirectoryResource();         for(File f : dr.selectedFiles()){             ImageResource image = new ImageResource(f);             String fname = image.getFileName();             String newfname = "copy-" + fname;             image.setFileName(newfname);             image.draw();             image.save();         }     }     }

Batch Gratscale Image Code --Java Programming: Solving Problems with Software

import edu.duke.*; import java.io.File; public class GrayScaleConverter {     //started with the image i wanted(inImage)     public ImageResource makeGray(ImageResource inImage){     //I Made a blank image of the same size         ImageResource outImage = new ImageResource(inImage.getWidth(),inImage.getHeight());     //for each pixelin outImage         for(Pixel pixel : outImage.pixels()){     //look at the corresponding pixel in inImage             Pixel inPixel = inImage.getPixel(pixel.getX(),pixel.getY());     //compute inPixel's red + inPixel's blue + inpixel's green     //divide that sum by 3(call it average)     int average = (inPixel.getRed()+inPixel.getGreen()+inPixel.getBlue())/3;     //set pixel's red to average     pixel.setRed(average);     //set pixel's green to average     pixel.setGreen(average);     //set pixel's blur to average     pixel.setBlue(average);     }      return outImage;     }       public void SelectAndConvert(){         DirectoryR

Grayscaling An Image One At A Time -- Java Programming: Solving Problems with Software

/**  * Write a description of GrayScaleConverter here.  *  * @author (your name)  * @version (a version number or a date)  */ import edu.duke.*; public class GrayScaleConverter {     //started with the image i wanted(inImage)     public ImageResource makeGray(ImageResource inImage){     //I Made a blank image of the same size         ImageResource outImage = new ImageResource(inImage.getWidth(),inImage.getHeight());     //for each pixelin outImage         for(Pixel pixel : outImage.pixels()){     //look at the corresponding pixel in inImage             Pixel inPixel = inImage.getPixel(pixel.getX(),pixel.getY());     //compute inPixel's red + inPixel's blue + inpixel's green     //divide that sum by 3(call it average)     int average = (inPixel.getRed()+inPixel.getGreen()+inPixel.getBlue())/3;     //set pixel's red to average     pixel.setRed(average);     //set pixel's green to average     pixel.setGreen(average);     //set pixel's blur to average     pixel.set

Display the Name Of The Selected Files For GreyScale --Java Programming: Solving Problems with Software

/**  * Write a description of greyscale here.  *  * @author (your name)  * @version (a version number or a date)  */ import edu.duke.*; import java.io.*; public class greyscale {     public void checkdir(){             DirectoryResource dr = new DirectoryResource();                 for (File f : dr.selectedFiles())         {                     System.out.println(f);         }     }         }
public class DaysAlivePrinter {     public static void main(String[] args)     {         // Sally Ride was born on May 26 1951         Day birthday = new Day (1951 , 5 , 26);                 // Her last day was July 23 2012         Day Lastday = new Day (2012 , 7 , 23);         // Use Day objects to calculate and print         int DaysAlive = Lastday.daysFrom(birthday);         // how many days she lived.         System.out.println(DaysAlive);         // You'll want to use the daysFrom method.         // Do you expect to get a negative or a positive number of days?     } }

Java Programming: Solving Problems with Software,

// You can use this program to run experiments // 1. Add statements inside main // 2. Compile // 3. Right-click on the Test rectangle and select main // 4. Click Ok on the next dialog // 5. The output is displayed in a terminal window public class Test {     public static void main(String[] args)     {         // Add something inside the ( )         //compile time error         //System.out.println(a b);         //prints total and in only one line         //System.out.print(3+4+5);         //runtme Error         //System.out.println(1/0);         //prints total and goes to the next line         //System.out.println(3+4+5);         //prints the string as it is "3+4+5"         //System.out.println("3+4+5");         // Add more statements below, as needed         System.out.print("My Lucky number is");         System.out.println(3 + 4 + 5);     } }

Practice Quiz : "Hello!!" Around The World --Java Programming: Solving Problems with Software

Image

week 1, Lesson 3 of 6: "Hello!" around the World, Iterables in Java Module --Java Programming: Solving Problems with Software

https://www.coursera.org/learn/java-programming/supplement/6CLKD/module-learning-outcomes-resources Iterables in Java Module In this module, you will learn to design and run your first Java programs, including one program that prints “Hello!” in various countries’ languages and another where you will copy and edit many files by converting color images to grayscale. To accomplish these tasks, you will learn about classes constructed for this course: Libraries of iterables that allow you to perform the same task over multiple lines in a document or web page or multiple files within a directory. By the end of this module, you will be able to: Download and run BlueJ, the Java programming environment for this course; Access the documentation for the Java libraries specially designed for this course; Edit, compile, and run a Java program; Construct for loops in Java; and Use Iterables to run a program that iterates over multiple lines in a document or webpage or multiple f

“Java Programming: Solving Problems with Software”

Welcome to “Welcome to “Java Programming: Solving Problems with Software”! We are excited that you are starting our course to learn how to write programs in Java, one of the most popular programming languages in the world. In this introductory module, you will get to meet the instructor team from Duke University, have an overview of the course, and hear from Google engineers about why they find programming exciting and why Java is important. Have fun!”! We are excited that you are starting our course to learn how to write programs in Java, one of the most popular programming languages in the world. In this introductory module, you will get to meet the instructor team from Duke University, have an overview of the course, and hear from Google engineers about why they find programming exciting and why Java is important. Have fun!

http://www.dukelearntoprogram.com/course1/example/index.php

// write your code here //Function returns chopped pixel color values function pixchange(pixval){     var x = Math.floor(pixval/4) * 4;     return x; } //Code section chops bits of pixel colors of image that hides another image function chop2hide(image){     for(var px of image.values()){         px.setRed(pixchange(px.getRed()));         px.setGreen(pixchange(px.getGreen()));         px.setBlue(pixchange(px.getBlue()));     }     return image; } //Code Section used to shift bits of pixel colors of image to be hidden function shift(im){   var nim = new SimpleImage(im.getWidth(),im.getHeight());   for(var px of im.values()){     var x = px.getX();     var y = px.getY();     var npx = nim.getPixel(x,y);     npx.setRed(Math.floor(px.getRed()/64));     npx.setGreen(Math.floor(px.getGreen()/64));     npx.setBlue(Math.floor(px.getBlue()/64));   }   return nim; } //Function returns cropped images function crop(image,w,h){     var img = new SimpleImage(w,h);
Image
<p>The following picture was given with a hidden message to extract:</p> <center><img src = "http://i36.photobucket.com/albums/e42/Samksha/hiltonHiding2bitMessage_zpsze7d7x8e.png" /></center> <p>After extraction, this is what the hidden message was!</p> <center><img src = "http://i36.photobucket.com/albums/e42/Samksha/Part%203_zpsmdhehkly.png"/></center> <h3> Algorithm</h3> <p> The algorithm used for the extraction is similar to the one used for extraction in the first part.</p> <h3> Code</h3> <pre> function pchange(pixval) {     var x = (pixval-Math.floor(pixval/4)*4)*64;     return x; } function extract(image) {     for(var pixel of image.values())     {         pixel.setRed(pchange(pixel.getRed()));         pixel.setGreen(pchange(pixel.getGreen()));         pixel.setBlue(pchange(pixel.getBlue()));     }     return image; } var co

nice one

Image
 Steganography Original Images This is the image that will be used to hide the second image! And this is the image that will be hidden in the first image! Sources for the images: https://www.hdwallpapers.net/abstract/colorful-diamond-wallpaper-674.htm https://www.hdwallpapers.net/abstract/dark-wood-texture-wallpaper-383.htm After the Hiding This is what the image looks like with the hidden value: And this is what the hidden image looks like after it is extracted: Algorithm The algorithm used to hide an image inside another using 2 bits is quite similar to the 4 bits, but has some distinctive differences. Instead of using 2^4, or 16, as the number used for dividing, we will be using 2^2, or 4. The first two bits of the image to be hidden are selected using the shift function. Since it's a 2 bit hidden message, we take the two most significant bits of the image we are hiding, i.e., "Diamond.jpg", by dividing the pixel value

Hide And Extract Image 2 bits

Image
//Function returns chopped pixel color values function pixchange(pixval){     var x = Math.floor(pixval/4) * 4;     return x; } //Code section chops bits of pixel colors of image that hides another image function chop2hide(image){     for(var px of image.values()){         px.setRed(pixchange(px.getRed()));         px.setGreen(pixchange(px.getGreen()));         px.setBlue(pixchange(px.getBlue()));     }     return image; } //Code Section used to shift bits of pixel colors of image to be hidden function shift(im){   var nim = new SimpleImage(im.getWidth(),im.getHeight());   for(var px of im.values()){     var x = px.getX();     var y = px.getY();     var npx = nim.getPixel(x,y);     npx.setRed(Math.floor(px.getRed()/64));     npx.setGreen(Math.floor(px.getGreen()/64));     npx.setBlue(Math.floor(px.getBlue()/64));   }   return nim; } //Function returns cropped images function crop(image,w,h){     var img = new SimpleImage(w,h);     for (var pi

Modify Image Algorithmically

Image
function ensureInImage(coordinate, size){     //coordinate cannot be negative     if (coordinate < 0){         return 0;     }     //coordinate size must be between [0....size-1]     if (coordinate >= size){         return size-1;     }     else{         return coordinate;     }   } function getPixelNearby(image , x, y, diameter){     var dx = Math.random() * diameter - diameter/2;     var dy = Math.random() * diameter - diameter/2;     var nx = ensureInImage(x + dx, image.getWidth());     var ny = ensureInImage(y + dy, image.getHeight());     return image.getPixel(nx, ny); } //Select An Image from the list var image = new SimpleImage ("chapel.png"); //I'm gonna create a new image that is the same size as my starting image. var output = new SimpleImage(image.getWidth() , image.getHeight() ); //for all the values of pixel of the image the values of x and y are taken and math.random is done since we dont want the new pixel more than the ra

Creating a Image Algorithmic-ally

Image
function dist(pixel,x,y){     var dx = pixel.getX() - x ;     var dy = pixel.getY() - y ;     return Math.sqrt(dx * dx + dy * dy); } // start with a blank image var output = new SimpleImage(320,320); // write something here for (var pixel of output.values()){     if (dist(pixel,100,100) < 50 ){         pixel.setRed(255 - 4 * dist (pixel,100,100));     }     else if (dist(pixel,200,200) < 80 ){         pixel.setGreen(255 - 4 * dist (pixel,200,200));     }               else if (Math.random() > 0.995 ){         pixel.setRed(255);         pixel.setGreen(255);     }     pixel.setBlue(Math.max(1.05 * pixel.getY() - pixel.getX() ,  pixel.getX() - 1.5 * pixel.getY() )) } print (output); OR //all the points here are numbered in the same way the numbers are displayed in code as comments // Since The Function Is Called It runs And creates a circle function dist(pixel,x,y){          var dx = pixel.getX() - x ;     var dy = pixel.getY() -

QUIZ Steganography Extraction and Duplication solutions

Image

Suppose we decide to write a function to set the color of a pixel by giving it three RGB values. Think about what the parameters and the code would need to be for this function. Let’s call the function setColor. Which one of the following is a correct setColor function?

// write your code here function clearbits(colorval){     //compute the same color value with the lowest bits zeroed     var x = Math.floor(colorval/16)*16;     return x; } function setColor( r, g, b) {     for (var pixel of start.values()){         pixel.setRed(r);      pixel.setGreen(g);    pixel.setBlue(b);     } return start; } function chop2hide(image){     //for each pixel in the image     for (var px of image.values()){         //clear the lower values of red         px.setRed(clearbits(px.getRed()));         //clear the lower values of green         px.setGreen(clearbits(px.getGreen()));         //clear the lower values of blue         px.setBlue(clearbits(px.getBlue()));     }     return image; } function shift(image){     //for each pixel in an image     for (var px of image.values()){         //shift the red bits over         px.setRed(px.getRed()/16);         //shift the Green bits over         px.setGreen(px.getGreen()/16);         //

EXTRACTION OF IMAGE code

// write your code here function clearbits(colorval){     //compute the same color value with the lowest bits zeroed     var x = Math.floor(colorval/16)*16;     return x; } function chop2hide(image){     //for each pixel in the image     for (var px of image.values()){         //clear the lower values of red         px.setRed(clearbits(px.getRed()));         //clear the lower values of green         px.setGreen(clearbits(px.getGreen()));         //clear the lower values of blue         px.setBlue(clearbits(px.getBlue()));     }     return image; } function shift(image){     //for each pixel in an image     for (var px of image.values()){         //shift the red bits over         px.setRed(px.getRed()/16);         //shift the Green bits over         px.setGreen(px.getGreen()/16);         //shift the Blue bits over         px.setBlue(px.getBlue()/16);     }     return image; } function open(imagetoopen){     for (var px of imagetoopen.values()){     var o

doubling image size

// write your code here //selecting the image i wanted to enlarge var smallImage = ("smalllion.jpg"); //creating a blank image which is having twice as size of original image var bigImage =   ("smallImage.getWidth() *2 , smallImage.getHeight() *2"); for (var px of bigImage.values()){     var x = px.getX();     var y = px.getY();     var calx = Math.floor(x/2);     var caly = Math.floor(y/2);     var smallPixel = smallImage.getPixel(calx,caly);     px.setRed(smallPixel.getRed());     px.setGreen(smallPixel.getGreen());     px.setBlue(smallPixel.getBlue()); } print (bigImage);

Select two images to use. You will hide one image in another image. They most likely will be different sizes and in the next step we will crop both of them to be the same size. In order to hide one image inside of another image, the images need to be the exact same size. Write the function crop(image, width, height) that has three parameters: image is a complete image, and width and height are numbers. This function creates and returns a new image from the parameter image, with the new image having the width and height of the specified width and height parameters, thus cropping the picture by ignoring the pixels on the right side or bottom that are beyond the specified width or height of the picture.

function clearbits(colorval){     //compute the same color value with the lowest bits zeroed     var x = Math.floor(colorval/16)*16;     return x; } function chop2hide(image){     //for each pixel in the image     for (var px of image.values()){         //clear the lower values of red         px.setRed(clearbits(px.getRed()));         //clear the lower values of green         px.setGreen(clearbits(px.getGreen()));         //clear the lower values of blue         px.setBlue(clearbits(px.getBlue()));     }     return image; } function shift(image){     //for each pixel in an image     for (var px of image.values()){         //shift the red bits over         px.setRed(px.getRed()/16);         //shift the Green bits over         px.setGreen(px.getGreen()/16);         //shift the Blue bits over         px.setBlue(px.getBlue()/16);     }     return image; } function combine(start,Hide){     //make a new image of the same size as SHOW (Call it Answer)     var a
function setBlack(pixel) {      pixel.setRed(0);      pixel.setGreen(0);      pixel.setBlue(0);      return pixel; } function pixelOnEdgeDifferentThicknesses (pixel, image, vWidth, hWidth) {      var x = pixel.getX();      var y = pixel.getY();      if (x < vWidth) return true;      if (y < hWidth) return true;      if (x >= image.getWidth() - vWidth) return true;      if (y >= image.getHeight() - hWidth) return true;      return false; } var image = new SimpleImage("usain.jpg"); for (var pixel of image.values()) {      if (pixelOnEdgeDifferentThicknesses (pixel, image, 10, 40)) {                 pixel = setBlack(pixel);      } } print(image);

Consider the following program from the lesson, shown below with missing code to add a border of 30 to the image. Consider the following sections of code that call the pixelOnEdge function in different ways. Select the three of them that will still run correctly and put a border of 30 around the image.

function setBlack(pixel) {      pixel.setRed(0);      pixel.setGreen(0);      pixel.setBlue(0);      return pixel; } function pixelOnEdge (pixel, image, borderWidth) {      var x = pixel.getX();      var y = pixel.getY();      if (x < borderWidth) return true;      if (y < borderWidth) return true;      if (x >= image.getWidth() - borderWidth) return true;      if (y >= image.getHeight() - borderWidth) return true;      return false; } var image = new SimpleImage("usain.jpg"); for (var pixel of image.values()) {     if (pixelOnEdge(pixel, image, 30)) {       pixel = setBlack(pixel);      } } print(image); OR function setBlack(pixel) {      pixel.setRed(0);      pixel.setGreen(0);      pixel.setBlue(0);      return pixel; } function pixelOnEdge (pixel, image, borderWidth) {      var x = pixel.getX();      var y = pixel.getY();      if (x < borderWidth) return true;      if (y < borderWidth) return

The function moreRed should increase the color of the red value of a pixel by a specified amount so that after executing the code which calls this function (shown below) then the picture is more red by adding 100 to each pixel’s red value.

Which one of the following is the correct implementation of moreRed ? // write your code here function moreRed(pixel, amount) {      var r = pixel.getRed() + amount;      if (r > 255)  r = 255;      pixel.setRed(r);      return pixel; } var image = new SimpleImage ("eastereggs.jpg"); print (image); for ( var pixel of image.values()){     if (moreRed(pixel, 200) ){             }     } print (image);

The function swapRedGreen has one parameter, a pixel. This function swaps the red and green values and returns the resulting red, green and blue values somehow. Which one of the following is the correct code for this function?

// write your code here function swapRedGreen(pixel) {      var newGreen = pixel.getRed();      var newRed = pixel.getGreen();      pixel.setGreen(newGreen);      pixel.setRed(newRed);      return pixel; } var image = new SimpleImage ("eastereggs.jpg"); print (image); for ( var pixel of image.values()){     if (swapRedGreen(pixel) ){             }     } print (image);

Now modify the program one more time to replace the two functions pixelOnVerticalEdge and pixelOnHorizontalEdge with one function to do the same thing called pixelOnEdgeDifferentThicknesses( ). The parameters are not shown. You should decide on the parameters. Write the function and test it to make sure it works the same as the two functions it replaces, so you can generate pictures with borders that have different thicknesses for the vertical borders vs. the horizontal borders. Here is an example: Here is an island picture:

Image
// write your code here function setBlack(pixel){     pixel.setBlue(0);     pixel.setGreen(0);     pixel.setRed(0);     return pixel; } function pixelOnEdgeDifferentThicknesses(pixel, image, borderWidth){     var x = pixel.getX();     var y = pixel.getY();       if (x < borderWidth) return true;     if (y < (borderWidth+40)) return true;     if (x >= image.getWidth() - borderWidth) return true;     if (y >= image.getHeight() - (borderWidth+40)) return true;     return false; } var image = new SimpleImage ("lion.jpg"); print (image); for ( var pixel of image.values()){     if (pixelOnEdgeDifferentThicknesses(pixel, image, 25) ){         pixel = setBlack(pixel);     }     } print (image); Here is the island picture with a border around it: Here is a picture of the island with different thicknesses for the vertical versus horizontal borders:

Now modify the border program to specify two thicknesses, one for the vertical borders and one for the horizontal borders. You should write the two boolean functions shown below. Be sure to print the image and run your program with different border values for the horizontal and vertical edges. a) function pixelOnVerticalEdge(pixel, image, borderWidth)—This function has three parameters where pixel is a single pixel, image is the complete image, and borderWidth is an integer specifying the thickness of the vertical borders. This function returns true if the pixel’s location is within borderWidth of any of the two vertical borders, and thus on the border. Otherwise it returns false. b) function pixelOnHorizontalEdge(pixel, image, borderWidth)—This function has three parameters where pixel is a single pixel, image is the complete image, and borderWidth is an integer specifying the thickness of the horizontal borders. This function returns true if the pixel’s location is within borderWidth of any of the two horizontal borders, and thus on the border. Otherwise it returns false.

Image
// write your code here function setBlack(pixel){     pixel.setBlue(0);     pixel.setGreen(0);     pixel.setRed(0);     return pixel; } function pixelOnVerticalEdge(pixel, image, borderWidth){     var x = pixel.getX();     var y = pixel.getY();       if (x < borderWidth) return true;         if (x >= image.getWidth() - borderWidth) return true;     return false; } function pixelOnHorizontalEdge(pixel, image, borderWidth){     var x = pixel.getX();     var y = pixel.getY();     if (y < borderWidth) return true;         if (y >= image.getHeight() - borderWidth) return true;         return false; } var image = new SimpleImage ("lion.jpg"); print (image); for ( var pixel of image.values()){     if (pixelOnHorizontalEdge(pixel, image, 25) ){         pixel = setBlack(pixel);     }     if (pixelOnVerticalEdge(pixel, image, 40)){         pixel = setBlack(pixel);     }     } print (image);

Write the complete JavaScript program to put the border around a picture, and include the following functions that are included from the lesson. You should be able to write these functions without looking at the code from the lesson. Be sure to print the image so you can see it and run the program with different border values. a) function setBlack(pixel) - This function has a parameter pixel that represents a single pixel, and returns a pixel that has been changed to be the color black. b) function pixelOnEdge(pixel, image, borderWidth) - This function has three parameters where pixel is a single pixel, image is the complete image, and borderWidth is an integer specifying the thickness of the borders. This function returns true if the pixel’s location is within borderWidth of any of the four borders, and thus on the border. Otherwise it returns false.

// write your code here function setBlack(pixel){     pixel.setBlue(0);     pixel.setGreen(0);     pixel.setRed(0);     return pixel; } function pixelOnEdge(pixel,image,borderWidth){     var x = pixel.getX();     var y = pixel.getY();     if (x < borderWidth) return true;     if (y < borderWidth) return true;     if (x >= image.getWidth() - borderWidth) return true;     if (y >= image.getHeight() - borderWidth) return true;     return false; } var image = new SimpleImage ("lion.jpg"); print (image); for ( var pixel of image.values()){     if (pixelOnEdge(pixel,image,10)){         pixel = setBlack(pixel);     } } print (image);

Write a JavaScript program that has a function named swapRedGreen with one parameter pixel. This function should swap the red and green values of the pixel. Pick an image, print the image, then apply swapRedGreen to every pixel in the image, and print the new image. The choice of your image is important. For some images you may not notice any change. Think about what type of image you should use for testing your function.

Image
// write your code here function swapRedGreen(pixel){     G = pixel.getGreen();     R = pixel.getRed();     if (G >= 200 ){         pixel.setRed(255);         pixel.setGreen(0);         return true     }     if (R >= 200){         pixel.setRed(0);         pixel.setGreen(255);         return true;     } } var image = new SimpleImage("smallhands.png"); print (image); for (pixel of image.values()){     pixel = swapRedGreen(pixel); } print (image);