This repository has been archived by the owner on Feb 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkonvoluce2_old.php
78 lines (62 loc) · 1.94 KB
/
konvoluce2_old.php
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
$maska[] = array(1,1,1);
$maska[] = array(1,9,1);
$maska[] = array(1,1,1);
$velikost["maska"] = sizeof($maska);
//vypocet konstanty
for($i=0; $i<=sizeof($velikost["maska"]); $i++) {
for($j=0; $j<=sizeof($velikost["maska"]); $j++) {
$con = $con + $maska[$i][$j]; //konstanta
}
}
//schody
/*
$input[] = array(0,0,0,0,0,0,0,0,0,63);
$input[] = array(0,0,0,0,0,0,0,0,63,63);
$input[] = array(0,63,0,0,0,0,0,63,63,63);
$input[] = array(0,0,0,0,0,0,63,63,63,63);
$input[] = array(0,0,0,0,0,63,63,63,63,63);
$input[] = array(0,0,0,0,0,63,63,63,63,63);
$input[] = array(0,0,0,63,63,63,63,63,63,63);
$input[] = array(0,0,0,63,63,63,63,63,63,63);
$input[] = array(0,0,0,63,63,63,63,63,63,63);
$input[] = array(63,63,63,63,63,63,63,63,63,63);
$input[] = array(63,63,63,63,63,63,63,63,63,63);
*/
$input[] = array(0,0,0,0,0);
$input[] = array(0,0,0,0,0);
$input[] = array(0,0,9,0,0);
$input[] = array(0,0,0,0,0);
$input[] = array(0,0,0,0,0);
$input[] = array(0,0,1,0,0);
$input[] = array(0,0,0,0,0);
$input[] = array(0,0,0,0,0);
//$vstup - vypocet velikosti
$velikost["x"] = sizeof($input[0]);
$velikost["y"] = sizeof($input);
for($x=0; $x<$velikost["y"]; $x++ ) {
for($y=0; $y<$velikost["x"]; $y++ ) {
$spodniHranice["x"] = $x-1;
$horniHranice["x"] = $x+1;
$spodniHranice["y"] = $y-1;
$horniHranice["y"] = $y+1;
$sum = 0;
$prumer = 0;
$maskaPozice["x"] = 0;
//aplikace masky
for($mx=$spodniHranice["x"]; $mx<$horniHranice["x"]; $mx++ ) {
$maskaPozice["y"] = 0;
for($my=$spodniHranice["y"]; $my<$horniHranice["y"]; $my++ ) {
$sum = $sum + ($maska[$maskaPozice["x"]][$maskaPozice["y"]] * $input[$x+$mx][$y+$my]); //soucet hodnot okoli (vc. bodu) s aplikovanou hodnotou masky
//echo $sum."<br>";
$maskaPozice["y"]++;
}
$maskaPozice["x"]++;
}
$prumer = round($sum / $con,0); //prumer zaokrouhlime na cela cisla
$vystup[$x][$y] = $prumer;
echo str_pad($vystup[$x][$y], 3, '_', STR_PAD_LEFT);
}
echo "<br>";
}
?>