I have to create a lab that will
Print out the input 2D-array as an image on the console screen.
• Replace 0 by “ ” {space}.
• Replace values between 1 and 99 by “.” {one dot}.
• Replace values between 100 and 199 by “..” {two dots}.
• Replace values between 200 and 254 by “…” {three dots}.
• Replace 255’s by “x”.
- Remember to check if the dimensions of input array are valid numbers.
- Make use of method printf properly to print out the image nicely.
2.
- Change all numbers n in the array by (255-n).
- Print out the new matrix as well as the new image (using method Display).
- Remember to check if the dimensions of input array are valid numbers.
3.- Look for the pattern array inside the image.
- Erase the places where the pattern is found, i.e., change them to black (0).
- Print the 2D-array: before, and after if the pattern has been found.
- Return 1 if pattern is found, 0 otherwise.
- Example:
Image ( Before )
0 0 0 0 0
0 234 123 0 0
78 56 34 234 34
187 0 26 190 0
0 190 36 0 23
Pattern
0 234 123 0
78 56 34 234
Image ( After )
0 0 0 0 0
0 0 0 0 0
0 0 0 0 34
187 0 26 190 0
0 190 36 0 23
public class Lab7 { public static void Display(int[][] image) { for(int i = 0; i < image.length; i++) //rows { for(int j = 0; j < image[0].length; j++) //columns { if(image[i][j] == 0) System.out.print(" "); else if(image[i][j] >= 1 && image[i][j] <= 99) System.out.print(" . "); else if(image[i][j] >= 100 && image[i][j] <= 199) System.out.print(" .. "); else if(image[i][j] >= 200 && image[i][j] <= 254) System.out.print(" ... "); else System.out.print(" x "); } System.out.println(); } }//end method public static void Modify(int[][] image) { int[][] modImage = new int[10][10]; int n; for(int i = 0; i < image.length; i++) //rows { for(int j = 0; j < image[0].length; j++) //columns { n = (255 - image[i][j]); modImage [i][j]= n; } } Display(modImage); }//end method public static int extractFeature(int[][] image, int[][] pattern) { int[][] extractImage = new int[10][10]; int found = 0; return found; }//end method
I am Having Problems putting together the method extract feature if anyone can guide me in the right direction to have a working method? that is the only one that I need help with.