python - OpenCV - Disable all pixel alteration when saving as JPEG -


i'm writing utility least significant bit (lsb) steganography in python (2 , 3 compatability) opencv-python package (opencv-python==3.2.0.8). seems work flawlessly numerous png files i've tested, i've noticed that, seemingly no matter what, jpeg files have pixels altered every time call cv2.imwrite. here's save method lsbcodec class:

class lsbcodec(object):     # ...      def save(self, filename):         ext = filename.split(".")[-1].lower()  # assumptions made          if ext in ("jpg", "jpeg", "jpe"):             args = [[int(cv2.imwrite_jpeg_quality), 100]]         elif ext in ("png",):             args = [[int(cv2.imwrite_png_compression), 0]]         else:             args = []         cv2.imwrite(filename, self.img, *args) 

however, still alters pixels. altering them 1 bit throws off entire program (since least significant bits used data , metadata storage).

for example, first 3 bits should either 0's or 1's , determine if simple xor key should provided decoding data. second 3 bits determine number of least significant bits use following data. using 2 bits , no xor key, value encoded should 0b000010 (but stored reversed) spread out on first 2 pixels (6 channels).

original first 2 pixels:
[ 44 120 216], [ 43 119 215] last bits: 000111

encoded first 2 pixels:
[ 44 121 216], [ 42 118 214] last bits: 010000 (reversed)

stored first 2 pixels:
[ 44 121 217], [ 42 118 214] should same above

how can save jpeg file without altering pixels in way? or not feasible because of jpeg image codec unfamiliar? work if changed extension png?


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -