MCPcopy
hub / github.com/ShieldMnt/invisible-watermark / encode_frame

Method encode_frame

imwatermark/maxDct.py:112–134  ·  view source on GitHub ↗

frame is a matrix (M, N) we get K (watermark bits size) blocks (self._block x self._block) For i-th block, we encode watermark[i] bit into it

(self, frame, scale)

Source from the content-addressed store, hash-verified

110 return 0
111
112 def encode_frame(self, frame, scale):
113 '''
114 frame is a matrix (M, N)
115
116 we get K (watermark bits size) blocks (self._block x self._block)
117
118 For i-th block, we encode watermark[i] bit into it
119 '''
120 (row, col) = frame.shape
121 num = 0
122 for i in range(row//self._block):
123 for j in range(col//self._block):
124 block = frame[i*self._block : i*self._block + self._block,
125 j*self._block : j*self._block + self._block]
126 wmBit = self._watermarks[(num % self._wmLen)]
127
128
129 diffusedBlock = self.diffuse_dct_matrix(block, wmBit, scale)
130 #diffusedBlock = self.diffuse_dct_svd(block, wmBit, scale)
131 frame[i*self._block : i*self._block + self._block,
132 j*self._block : j*self._block + self._block] = diffusedBlock
133
134 num = num+1

Callers 1

encodeMethod · 0.95

Calls 1

diffuse_dct_matrixMethod · 0.95

Tested by

no test coverage detected