jpegio icon indicating copy to clipboard operation
jpegio copied to clipboard

jpegio.write saves the original coefs rather than the modified coefs

Open zhahongyue opened this issue 2 years ago • 5 comments

I have to modify a grayscale jpeg's dct coef and save it to another path. But it seems that jpegio.write() saves the original coefs rather than the modified coefs. Could you please check this out for me? Thanks a lot!

######################################

import jpegio as jio #jpegio version is 0.2.2 import imageio import numpy as np

cover = jio.read(cover_path) cover_coef_input = np.array(cover.coef_arrays[0]) cover.coef_arrays[0] = cover.coef_arrays[0] + pert
cover_coef_modified = np.array(cover.coef_arrays[0]) jio.write(cover, stego_path)

cover = jio.read(cover_path) cover_coef = np.array(cover.coef_arrays[0]) cover_spatial = imageio.imread(cover_path) stego = jio.read(stego_path)
stego_coef = np.array(stego.coef_arrays[0])
stego_spatial = imageio.imread(stego_path)

print('num_cin_cm_diff:',np.sum(cover_coef_modified!=cover_coef_input)) # 1034 print('num_cin_c_diff:',np.sum(cover_coef!=cover_coef_input)) # 0 print('num_c_s_diff:',np.sum(cover_coef!=stego_coef)) # 0 print('num_cm_s_diff:',np.sum(cover_coef_modified!=stego_coef)) # 1034 print('num_c_s_spatial_diff:',np.sum(cover_spatial!=stego_spatial)) # 0

zhahongyue avatar Aug 05 '22 01:08 zhahongyue

Thanks for reporting the issue. Could you please upload or send me an example file (i.e., the grayscale JPEG file)?

dwgoon avatar Aug 15 '22 10:08 dwgoon

cover.zip Thanks for your consideration. Some example grayscale JPEG files are in the above zip file url.

zhahongyue avatar Aug 15 '22 10:08 zhahongyue

I faced the same issue, when I tried to modify the coefficients in my image. So I guess there is no solution for now?

johtai avatar Dec 02 '23 20:12 johtai