Commit dceec280c6b6bd28ae9fb2bd962dc26fef8d9ebe
1 parent
873557f9
Exists in
master
get capacity.
Showing
10 changed files
with
18 additions
and
5 deletions
Show diff stats
mjpeg/__init__.py
... | ... | @@ -257,11 +257,11 @@ class Jpeg(Jsteg): |
257 | 257 | colour channel (as a 4-D tensor: (v,h,row,col)). |
258 | 258 | """ |
259 | 259 | if channel == "All": |
260 | - return [ | |
261 | - np.array([np.hsplit(arr, arr.shape[1] / 8) for arr in np.vsplit(compMat, compMat.shape[0] / 8)]) | |
262 | - for compMat in self.coef_arrays] | |
260 | + return np.array([ | |
261 | + [np.hsplit(arr, arr.shape[1] / 8) for arr in np.vsplit(compMat, compMat.shape[0] / 8)] for compMat in | |
262 | + self.coef_arrays]) | |
263 | 263 | |
264 | - compMat = self.getCoefMatrix(channel="Y") | |
264 | + compMat = self.getCoefMatrix(channel) | |
265 | 265 | return np.array([np.hsplit(arr, arr.shape[1] / 8) for arr in np.vsplit(compMat, compMat.shape[0] / 8)]) |
266 | 266 | |
267 | 267 | def getCoefBlock(self, channel="Y", loc=(0, 0)): |
... | ... | @@ -294,6 +294,14 @@ class Jpeg(Jsteg): |
294 | 294 | def getSize(self): |
295 | 295 | return self.image_width, self.image_height |
296 | 296 | |
297 | + def getCapacity(self, channel="All"): | |
298 | + blocks = self.getCoefBlocks(channel) | |
299 | + print blocks.shape | |
300 | + return (np.sum(blocks[0] != 0) - np.size(blocks[0]) / 64) + (np.sum(blocks[1] != 0) - np.size( | |
301 | + blocks[1]) / 64) / 4 + (np.sum(blocks[2] != 0) - np.size(blocks[2]) / 64) / 4 | |
302 | + # return np.sum(np.array(self.coef_arrays)!=0) - np.size(self.coef_arrays) / 64 | |
303 | + | |
304 | + | |
297 | 305 | def getQuality(self): |
298 | 306 | """ |
299 | 307 | Qaulity rating algorithm from ImageMagick. | ... | ... |
mjpeg/__init__.pyc
No preview for this file type
130 KB
119 KB
89.9 KB
172 KB
111 KB
62.9 KB
test_jpeg.py
... | ... | @@ -167,8 +167,9 @@ if __name__ == '__main__': |
167 | 167 | |
168 | 168 | # test_bitbyte() |
169 | 169 | |
170 | - ima = mjpeg.Jpeg("res/lena.jpg", key=sample_key) | |
170 | + ima = mjpeg.Jpeg("res/166500/cecdb4b3fef5433faa3d24259e3e4.jpg", key=sample_key) | |
171 | 171 | print ima.getQuality() |
172 | + print ima.getCapacity() | |
172 | 173 | sys.exit(0) |
173 | 174 | |
174 | 175 | # imb = mjpeg.Jpeg("res/new.jpg",key=sample_key) | ... | ... |
test_steg.py
... | ... | @@ -26,6 +26,7 @@ sample_key = [46812L, 20559L, 31360L, 16681L, 27536L, 39553L, 5427L, 63029L, 565 |
26 | 26 | txtsample = [116, 104, 105, 115, 32, 105, 115, 32, 116, 111, 32, 98, 101, 32, 101, 109, 98, 101, 100, 101, 100, 46, 10] |
27 | 27 | |
28 | 28 | if __name__ == '__main__': |
29 | + # f3test = F3.F3() | |
29 | 30 | # f3test = F4.F4(sample_key) |
30 | 31 | f3test = F5.F5(sample_key, 1) |
31 | 32 | # f3test.embed_raw_data("res/test3.jpg", "res/embeded", "res/steged.jpg") |
... | ... | @@ -34,6 +35,9 @@ if __name__ == '__main__': |
34 | 35 | # f3test2 = F4.F4(sample_key) |
35 | 36 | f3test.extract_raw_data("res/steged.jpg", "res/extracted.jpg") |
36 | 37 | print f3test.get_key() |
38 | + | |
39 | + # f5test = F5.F5(sample_key, 1) | |
40 | + | |
37 | 41 | pass |
38 | 42 | |
39 | 43 | ... | ... |