Commit dceec280c6b6bd28ae9fb2bd962dc26fef8d9ebe

Authored by Chunk
1 parent 873557f9
Exists in master

get capacity.

mjpeg/__init__.py
@@ -257,11 +257,11 @@ class Jpeg(Jsteg): @@ -257,11 +257,11 @@ class Jpeg(Jsteg):
257 colour channel (as a 4-D tensor: (v,h,row,col)). 257 colour channel (as a 4-D tensor: (v,h,row,col)).
258 """ 258 """
259 if channel == "All": 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 return np.array([np.hsplit(arr, arr.shape[1] / 8) for arr in np.vsplit(compMat, compMat.shape[0] / 8)]) 265 return np.array([np.hsplit(arr, arr.shape[1] / 8) for arr in np.vsplit(compMat, compMat.shape[0] / 8)])
266 266
267 def getCoefBlock(self, channel="Y", loc=(0, 0)): 267 def getCoefBlock(self, channel="Y", loc=(0, 0)):
@@ -294,6 +294,14 @@ class Jpeg(Jsteg): @@ -294,6 +294,14 @@ class Jpeg(Jsteg):
294 def getSize(self): 294 def getSize(self):
295 return self.image_width, self.image_height 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 def getQuality(self): 305 def getQuality(self):
298 """ 306 """
299 Qaulity rating algorithm from ImageMagick. 307 Qaulity rating algorithm from ImageMagick.
mjpeg/__init__.pyc
No preview for this file type
res/166500/221379062154e32d0efa5cce32f1b.jpg 0 → 100644

130 KB

res/166500/55df71faed43b37a8ac242120a72d.jpg 0 → 100644

119 KB

res/166500/988d826212a6eed023ab99284971d.jpg 0 → 100644

89.9 KB

res/166500/cecdb4b3fef5433faa3d24259e3e4.jpg 0 → 100644

172 KB

res/166500/e0255871e984f61ee8dc1800b9184.jpg 0 → 100644

111 KB

res/166500/tmp000.jpg 0 → 100644

62.9 KB

@@ -167,8 +167,9 @@ if __name__ == '__main__': @@ -167,8 +167,9 @@ if __name__ == '__main__':
167 167
168 # test_bitbyte() 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 print ima.getQuality() 171 print ima.getQuality()
  172 + print ima.getCapacity()
172 sys.exit(0) 173 sys.exit(0)
173 174
174 # imb = mjpeg.Jpeg("res/new.jpg",key=sample_key) 175 # imb = mjpeg.Jpeg("res/new.jpg",key=sample_key)
@@ -26,6 +26,7 @@ sample_key = [46812L, 20559L, 31360L, 16681L, 27536L, 39553L, 5427L, 63029L, 565 @@ -26,6 +26,7 @@ sample_key = [46812L, 20559L, 31360L, 16681L, 27536L, 39553L, 5427L, 63029L, 565
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] 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 if __name__ == '__main__': 28 if __name__ == '__main__':
  29 + # f3test = F3.F3()
29 # f3test = F4.F4(sample_key) 30 # f3test = F4.F4(sample_key)
30 f3test = F5.F5(sample_key, 1) 31 f3test = F5.F5(sample_key, 1)
31 # f3test.embed_raw_data("res/test3.jpg", "res/embeded", "res/steged.jpg") 32 # f3test.embed_raw_data("res/test3.jpg", "res/embeded", "res/steged.jpg")
@@ -34,6 +35,9 @@ if __name__ == '__main__': @@ -34,6 +35,9 @@ if __name__ == '__main__':
34 # f3test2 = F4.F4(sample_key) 35 # f3test2 = F4.F4(sample_key)
35 f3test.extract_raw_data("res/steged.jpg", "res/extracted.jpg") 36 f3test.extract_raw_data("res/steged.jpg", "res/extracted.jpg")
36 print f3test.get_key() 37 print f3test.get_key()
  38 +
  39 + # f5test = F5.F5(sample_key, 1)
  40 +
37 pass 41 pass
38 42
39 43