Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Intro to JAVA please see below thanks! -----------------------------------------

ID: 3916840 • Letter: I

Question

Intro to JAVA please see below thanks!

--------------------------------------------------------------------------------------------

In order to analyze images, one wants to isolate individual features. The first step is to locate feature boundaries through edge detection. In its simplest form, one compares each pixel with its neighbors. If the difference is large, color the pixel black; otherwise, color it white. We give you a Picture class that yields a two-dimensional array of gray levels. Process each pixel as described, but only take the average of the pixels to the right, bottom, and bottom right (so that you don’t evaluate pixels that were already processed). Leave the last row and column alone. Complete the following code.

CODE:

public class EdgeDetect
{
   public static void main(String[] args)
   {
      Picture picture = new Picture("eiffel-tower-picture.jpg");
      int[][] grays = picture.getGrayLevels();

      for (. . .)
      {
         for (. . .)
         {
            int neighborAverage = . . .;
            if (Math.abs(grays[i][j] - neighborAverage) > 20)
            {
               grays[i][j] = 0;             
            }
            else
            {
               grays[i][j] = 255;             
            }
         }       
      }
      Picture edges = new Picture(grays);
      edges.draw();
   }
}

Explanation / Answer

please give thumbs up, thanks.

public class EdgeDetect
{
   public static void main(String[] args)
   {
      Picture picture = new Picture("eiffel-tower-picture.jpg");
      int[][] grays = picture.getGrayLevels();

      for (int i=0; i<grays.length; i++)
      {
         for (
int j=0; j<grays[0].length; j++)
         {
            int neighborAverage =
(grays[i+1][j]+grays[i][j+1]+grays[i+1][j+1])/3;
            if (Math.abs(grays[i][j] - neighborAverage) > 20)
            {
               grays[i][j] = 0;             
            }
            else
            {
               grays[i][j] = 255;             
            }
         }       
      }
      Picture edges = new Picture(grays);
      edges.draw();
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote