Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. for(i = 1; i+1<h; i++) {
  2.             for(j = 1; j+1<w; j++) {
  3.  
  4.                 tl = (i >= roi.y && j >= roi.x);
  5.                 br = (i <= roi.y+roi.height && j <= roi.x+roi.width);
  6.  
  7.                 if(tl && br) {
  8.                     //(1   2  1)
  9.                     //(0   0  0)
  10.                     //(-1 -2 -1)
  11.  
  12.                     //(1 0 -1)
  13.                     //(2 0 -2)
  14.                     //(1 0 -1)
  15.  
  16.                     index = (i*w)+j;
  17.                     indexOL = ((i-1)*w)+j-1;
  18.                     indexO = ((i-1)*w)+j;
  19.                     indexOR = ((i-1)*w)+j+1;
  20.                     indexL = (i*w)+j-1;
  21.                     indexR = (i*w)+j+1;
  22.                     indexUL = ((i+1)*w)+j-1;
  23.                     indexU = ((i+1)*w)+j;
  24.                     indexUR = ((i+1)*w)+j+1;
  25.                    
  26.                     int pxOL = (int) pixelsin[indexOL]&0xff;
  27.                     int pxO  = (int) pixelsin[indexO]&0xff;
  28.                     int pxOR = (int) pixelsin[indexOR]&0xff;
  29.                     int pxL  = (int) pixelsin[indexL]&0xff;
  30.                     int px   = (int) pixelsin[index]&0xff;
  31.                     int pxR  = (int) pixelsin[indexR]&0xff;
  32.                     int pxUL = (int) pixelsin[indexUL]&0xff;
  33.                     int pxU  = (int) pixelsin[indexU]&0xff;
  34.                     int pxUR = (int) pixelsin[indexUR]&0xff;
  35.  
  36.                     wert = (1*pxOL + 2*pxO + 1*pxOR + -1*pxUL + -2*pxU + -1*pxUR) + 127;
  37.  
  38.                     if(wert < 0) {
  39.                         wert = 0;
  40.                     } else if(wert > 255) {
  41.                         wert = 255;
  42.                     }
  43.                    
  44.                     pixels[index] = (byte)wert;
  45.                 }
  46.             }
  47.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement