Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(i = 1; i+1<h; i++) {
- for(j = 1; j+1<w; j++) {
- tl = (i >= roi.y && j >= roi.x);
- br = (i <= roi.y+roi.height && j <= roi.x+roi.width);
- if(tl && br) {
- //(1 2 1)
- //(0 0 0)
- //(-1 -2 -1)
- //(1 0 -1)
- //(2 0 -2)
- //(1 0 -1)
- index = (i*w)+j;
- indexOL = ((i-1)*w)+j-1;
- indexO = ((i-1)*w)+j;
- indexOR = ((i-1)*w)+j+1;
- indexL = (i*w)+j-1;
- indexR = (i*w)+j+1;
- indexUL = ((i+1)*w)+j-1;
- indexU = ((i+1)*w)+j;
- indexUR = ((i+1)*w)+j+1;
- int pxOL = (int) pixelsin[indexOL]&0xff;
- int pxO = (int) pixelsin[indexO]&0xff;
- int pxOR = (int) pixelsin[indexOR]&0xff;
- int pxL = (int) pixelsin[indexL]&0xff;
- int px = (int) pixelsin[index]&0xff;
- int pxR = (int) pixelsin[indexR]&0xff;
- int pxUL = (int) pixelsin[indexUL]&0xff;
- int pxU = (int) pixelsin[indexU]&0xff;
- int pxUR = (int) pixelsin[indexUR]&0xff;
- wert = (1*pxOL + 2*pxO + 1*pxOR + -1*pxUL + -2*pxU + -1*pxUR) + 127;
- if(wert < 0) {
- wert = 0;
- } else if(wert > 255) {
- wert = 255;
- }
- pixels[index] = (byte)wert;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement