-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorDiffusion1D.java
More file actions
35 lines (32 loc) · 859 Bytes
/
ErrorDiffusion1D.java
File metadata and controls
35 lines (32 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.util.Scanner;
/**
*
* @author DarkShadowDemon200x
*/
public class ErrorDiffusion1D {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[][] I = new int[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
I[i][j] = sc.nextInt();
}
}
for (int i = 0; i < n; i++) {
int e = 0;
for (int j = 0; j < n; j++) {
int u = I[i][j] - e;
if(u < 127){
e = 0 - u;
I[i][j] = 0;
}else{
e = 255 - u;
I[i][j] = 255;
}
System.out.print(I[i][j] + " ");
}
System.out.println();
}
}
}