diff --git a/mjpeg/__init__.py b/mjpeg/__init__.py index ea481f2..53d3f4c 100644 --- a/mjpeg/__init__.py +++ b/mjpeg/__init__.py @@ -257,11 +257,11 @@ class Jpeg(Jsteg): colour channel (as a 4-D tensor: (v,h,row,col)). """ if channel == "All": - return [ - np.array([np.hsplit(arr, arr.shape[1] / 8) for arr in np.vsplit(compMat, compMat.shape[0] / 8)]) - for compMat in self.coef_arrays] + return np.array([ + [np.hsplit(arr, arr.shape[1] / 8) for arr in np.vsplit(compMat, compMat.shape[0] / 8)] for compMat in + self.coef_arrays]) - compMat = self.getCoefMatrix(channel="Y") + compMat = self.getCoefMatrix(channel) return np.array([np.hsplit(arr, arr.shape[1] / 8) for arr in np.vsplit(compMat, compMat.shape[0] / 8)]) def getCoefBlock(self, channel="Y", loc=(0, 0)): @@ -294,6 +294,14 @@ class Jpeg(Jsteg): def getSize(self): return self.image_width, self.image_height + def getCapacity(self, channel="All"): + blocks = self.getCoefBlocks(channel) + print blocks.shape + return (np.sum(blocks[0] != 0) - np.size(blocks[0]) / 64) + (np.sum(blocks[1] != 0) - np.size( + blocks[1]) / 64) / 4 + (np.sum(blocks[2] != 0) - np.size(blocks[2]) / 64) / 4 + # return np.sum(np.array(self.coef_arrays)!=0) - np.size(self.coef_arrays) / 64 + + def getQuality(self): """ Qaulity rating algorithm from ImageMagick. diff --git a/mjpeg/__init__.pyc b/mjpeg/__init__.pyc index 55cb514..6137b2a 100644 Binary files a/mjpeg/__init__.pyc and b/mjpeg/__init__.pyc differ diff --git a/res/166500/221379062154e32d0efa5cce32f1b.jpg b/res/166500/221379062154e32d0efa5cce32f1b.jpg new file mode 100644 index 0000000..e964d3d Binary files /dev/null and b/res/166500/221379062154e32d0efa5cce32f1b.jpg differ diff --git a/res/166500/55df71faed43b37a8ac242120a72d.jpg b/res/166500/55df71faed43b37a8ac242120a72d.jpg new file mode 100644 index 0000000..079a9b4 Binary files /dev/null and b/res/166500/55df71faed43b37a8ac242120a72d.jpg differ diff --git a/res/166500/988d826212a6eed023ab99284971d.jpg b/res/166500/988d826212a6eed023ab99284971d.jpg new file mode 100644 index 0000000..14baf83 Binary files /dev/null and b/res/166500/988d826212a6eed023ab99284971d.jpg differ diff --git a/res/166500/cecdb4b3fef5433faa3d24259e3e4.jpg b/res/166500/cecdb4b3fef5433faa3d24259e3e4.jpg new file mode 100644 index 0000000..ff4158d Binary files /dev/null and b/res/166500/cecdb4b3fef5433faa3d24259e3e4.jpg differ diff --git a/res/166500/e0255871e984f61ee8dc1800b9184.jpg b/res/166500/e0255871e984f61ee8dc1800b9184.jpg new file mode 100644 index 0000000..5955e04 Binary files /dev/null and b/res/166500/e0255871e984f61ee8dc1800b9184.jpg differ diff --git a/res/166500/tmp000.jpg b/res/166500/tmp000.jpg new file mode 100644 index 0000000..7c27679 Binary files /dev/null and b/res/166500/tmp000.jpg differ diff --git a/test_jpeg.py b/test_jpeg.py index 5e245af..9fe4f03 100644 --- a/test_jpeg.py +++ b/test_jpeg.py @@ -167,8 +167,9 @@ if __name__ == '__main__': # test_bitbyte() - ima = mjpeg.Jpeg("res/lena.jpg", key=sample_key) + ima = mjpeg.Jpeg("res/166500/cecdb4b3fef5433faa3d24259e3e4.jpg", key=sample_key) print ima.getQuality() + print ima.getCapacity() sys.exit(0) # imb = mjpeg.Jpeg("res/new.jpg",key=sample_key) diff --git a/test_steg.py b/test_steg.py index 098acf4..6942e3c 100644 --- a/test_steg.py +++ b/test_steg.py @@ -26,6 +26,7 @@ sample_key = [46812L, 20559L, 31360L, 16681L, 27536L, 39553L, 5427L, 63029L, 565 txtsample = [116, 104, 105, 115, 32, 105, 115, 32, 116, 111, 32, 98, 101, 32, 101, 109, 98, 101, 100, 101, 100, 46, 10] if __name__ == '__main__': + # f3test = F3.F3() # f3test = F4.F4(sample_key) f3test = F5.F5(sample_key, 1) # f3test.embed_raw_data("res/test3.jpg", "res/embeded", "res/steged.jpg") @@ -34,6 +35,9 @@ if __name__ == '__main__': # f3test2 = F4.F4(sample_key) f3test.extract_raw_data("res/steged.jpg", "res/extracted.jpg") print f3test.get_key() + + # f5test = F5.F5(sample_key, 1) + pass -- libgit2 0.21.2