Advertisement
Guest User

aaabbccaaabbcc

a guest
Dec 5th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public int[][] replaceNegatives( int[][] mat ) {
  2. for(int i=0;i<mat.length;i++){
  3. for(int e=0;e<mat[0].length;e++){
  4. if(mat[i][e]<0)
  5. mat[i][e]=-1*mat[i][e];
  6. }
  7. }
  8. return mat;
  9. }
  10.  
  11. public class GrayImage {
  12.  
  13. public static final int BLACK = 0;
  14. public static final int WHITE = 255;
  15.  
  16. private int[][] pixelValues;
  17.  
  18. public int countWhitePixels() {
  19. int a=0;
  20. for(int i=0;i<pixelValues.length;i++){
  21. for(int e=0;e<pixelValues[0].length;e++){
  22. if(pixelValues[i][e]==255)
  23. a++;
  24. }
  25. }
  26.  
  27. return a;
  28. }
  29.  
  30. public void processImage() {
  31. for(int i=0;i<pixelValues.length-2;i++){
  32. for(int e=0;e<pixelValues[0].length-2;e++){
  33. pixelValues[i][e]=pixelValues[i][e]-pixelValues[i+2][e+2];
  34. if(pixelValues[i][e]<0)
  35. pixelValues[i][e]=0;
  36. }
  37. }
  38.  
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement