Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Mask.php
1<?php
10
11class Mask implements \ArrayAccess
12{
13 protected $mask = [
14 [1, 1, 1],
15 [1, 1, 1],
16 [1, 1, 1],
17 ];
18
23 public function __construct(array $mask = null)
24 {
25 if($mask !== null)
26 {
27 $this->mask = $mask;
28 }
29 }
30
34 public function getValue()
35 {
36 return $this->mask;
37 }
38
42 public function getVector()
43 {
44 $result = [];
45 foreach ($this->mask as $row)
46 {
47 foreach ($row as $column)
48 {
49 $result[] = $column;
50 }
51 }
52 return $result;
53 }
54
59 public static function createSharpen($precision)
60 {
61 $mask = null;
62 if($precision > 0)
63 {
64 $k = 1.0/((int)$precision);
65 $mask = [
66 [-$k, -$k, -$k],
67 [-$k, 1+8*$k, -$k],
68 [-$k, -$k, -$k],
69 ];
70 }
71 return new static($mask);
72 }
73
74 public function offsetSet($offset, $value): void
75 {
76 if(is_null($offset))
77 {
78 $this->mask[] = $value;
79 }
80 else
81 {
82 $this->mask[$offset] = $value;
83 }
84 }
85
86 public function offsetExists($offset): bool
87 {
88 return isset($this->mask[$offset]);
89 }
90
91 public function offsetUnset($offset): void
92 {
93 unset($this->mask[$offset]);
94 }
95
96 #[\ReturnTypeWillChange]
97 public function offsetGet($offset)
98 {
99 return ($this->mask[$offset] ?? null);
100 }
101}
static createSharpen($precision)
Definition Mask.php:59
offsetSet($offset, $value)
Definition Mask.php:74
__construct(array $mask=null)
Definition Mask.php:23