def extract(self, window: np.ndarray) -> int: cnt = 0 avg = 0.5 * (window[0] + window[-1]) for i in range(1, len(window)): cnt += bit2sign(window[i] > avg) return int(cnt >= 0)
def extract(self, domain: np.ndarray) -> int: cnt = 0 even, odd = domain for e, o in zip(even, odd): cnt += bit2sign((e - o) >= 0) return int(cnt >= 0)
def extract(self, window: np.ndarray) -> int: cnt = 0 imin, imax = window.argmin(), window.argmax() for i, x in enumerate(window): if i != imin and i != imax: mid = (window[imin] + window[imax]) / 2 cnt += bit2sign(x >= mid) return int(cnt >= 0)
def embed(self, domain: np.ndarray, bit: int) -> np.ndarray: even, odd = domain bit = bit2sign(bit) for i in range(len(even)): avg = 0.5 * (even[i] + odd[i]) even[i] = avg + bit * self.alpha odd[i] = avg - bit * self.alpha return domain
def embed(self, window: np.ndarray, bit: int) -> np.ndarray: bit = bit2sign(bit) sm = window[0] + window[-1] window[1:-1] = 0.5 * (sm + bit * self.alpha * sm) return window