Reputation: 121
I have an array that I'm trying to blur using a kernel, but the loop doesn't finish for some reason, here's the code:
for (int x = 0; x < 128; x++) {
for (int y = 0; y < 128; y++) {
for (int kx = -2; x <= 6; x++) {
for (int ky = -2; y <= 6; y++) {
nlm2[x][y] += 100 * (int) ((float) nlm[x][y]*(float)kernel[(kx+3)*(ky+3)-1]);
System.out.println(x+" "+y);
System.out.println(kx+" NLM: "+(float) nlm[x][y]);
System.out.println(ky+" Kernel: "+(float)kernel[(kx+3)*(ky+3)-1]);
}
}
}
}
It seems to stop after x = 0; y = 6 kx = ky = -2
There are no errors in the console, and it shows another print screen after this little loop-de-loop.
Upvotes: 0
Views: 116
Reputation: 16526
This lines might be the problem.-
for (int kx = -2; x <= 6; x++) {
for (int ky = -2; y <= 6; y++) {
You're incrementing x
and y
respectively, instead of kx
and ky
.
I'm guessing you really meant.-
for (int kx = -2; kx <= 6; kx ++) {
for (int ky = -2; ky <= 6; ky ++) {
Upvotes: 5