Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void motionblur(int n){//n is blur amount
- System.out.println("Blur setting = " + n);
- if(n < 0) {
- System.out.println("ERROR. Blur setting must be more than 0.");
- System.exit(0);
- }
- for(int i = width - 1; i > 0; i++) {
- int numRows = n;
- if (i + n > width) {
- numRows = width - i;
- }
- for (int j = 0; j < height; j++) {
- int rAvg = 0;
- int gAvg = 0;
- int bAvg = 0;
- for(int k = 1; k < numRows; k++) {
- rAvg = image[j][i + k - 1].red;
- gAvg = image[j][i + k - 1].green;
- bAvg = image[j][i + k - 1].blue;
- }
- image[j][i].red = rAvg/numRows;
- image[j][i].green = gAvg/numRows;
- image[j][i].blue = bAvg/numRows;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement