Advertisement
MnMWizard

Module 8 open

Apr 30th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. //Mason Marnell
  2. //I just called both methods respectively and then explored the picture in the main
  3.  
  4. public void Open()
  5.   {
  6.     Pixel[][] pixels = this.getPixels2D();
  7.     for (int row = 0; row < pixels.length;row++)
  8.     {
  9.       for (int col = pixels[row].length / 2; col < pixels[row].length; col++)
  10.       {
  11.         Pixel pixelObj = pixels[row][(col-pixels[row].length / 2)];
  12.         pixelObj.setRed(0);
  13.       }
  14.       for (int col = row + 160; col < pixels[row].length; col++)
  15.       {
  16.         Pixel pixelObj = pixels[row][col];
  17.         pixelObj.setGreen(0);
  18.       }
  19.       for (int col = 0; col < row; col++)
  20.       {
  21.          
  22.           Pixel pixelObj = pixels[row][col];
  23.           double g = pixelObj.getAverage();
  24.           pixelObj.setRed((int) g);
  25.           pixelObj.setGreen((int) g);
  26.           pixelObj.setBlue((int) g);
  27.       }
  28.     }
  29.    
  30.   }
  31.  
  32.  
  33.   public void Combine(Picture sec)
  34.   {
  35.       Pixel[][] pixels = this.getPixels2D();
  36.       Pixel[][] pix2 = sec.getPixels2D();
  37.       int rowStop = Math.min(pixels.length, pix2.length);
  38.       int colStop = Math.min(pixels[0].length, pix2[0].length);
  39.     for (int row = 0; row < rowStop;row++)
  40.     {
  41.       for (int col = 0; col < colStop; col++)
  42.       {
  43.         Pixel pixelObj = pixels[row][col];
  44.         Pixel pixo2 = pix2[row][col];
  45.         int red = (pixelObj.getRed()+ pixo2.getRed() / 2);
  46.         int green = (pixelObj.getGreen() + pixo2.getGreen() / 2);
  47.         int blue = (pixelObj.getBlue() + pixo2.getBlue() / 2);
  48.         pixelObj.setRed(red);
  49.         pixelObj.setGreen(green);
  50.         pixelObj.setBlue(blue);
  51.       }
  52.     }
  53.    
  54.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement