Skip to content

Commit 36c5b2a

Browse files
committed
image pixel problem added
1 parent fa90c64 commit 36c5b2a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const image = [
2+
1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18,
3+
19, 20, 21, 22, 23, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
4+
];
5+
6+
const filter = [
7+
4, 6, 7, 3, 6, 55, 64, 3, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 7, 4, 5, 6, 1, 2, 0
8+
];
9+
let m = 6;
10+
let n = 7;
11+
let newImage = [];
12+
let trackIndex = [8, 9, 10, 11, 12];
13+
for (let i = 0; i < 20; i++) { //6 if 3*3
14+
let res = trackIndex[i] + n;
15+
trackIndex.push(res);
16+
}
17+
18+
for (let i = 0; i < image.length; i++) {
19+
if (trackIndex[i] || trackIndex[i] == 0) {
20+
let x = image[trackIndex[i]];
21+
newImage.push(x);
22+
}
23+
}
24+
25+
let sum = 0;
26+
for (let i = 0; i < newImage.length; i++) {
27+
let result = newImage[i] * filter[i];
28+
sum += result;
29+
}
30+
console.log(sum);

0 commit comments

Comments
 (0)