clc;clear;close all; load('encode.mat','M', 'N'); alpha = 80; im = double(imread('original.jpg'))/255; im2 = double(imread('snow.jpg'))/255; imsize = size(im); FA2=fft2(im2); FA=fft2(im); G=(FA2-FA)/alpha; GG=G; for i=1:imsize(1)*0.5 for j=1:imsize(2) GG(M(i),N(j),:)=G(i,j,:); end end for i=1:imsize(1)*0.5 for j=1:imsize(2) GG(imsize(1)+1-i,imsize(2)+1-j,:)=GG(i,j,:); end end imwrite(GG,'output5.jpg');
import numpy as np import cv2 as cv from matplotlib import pyplot as plt import struct M=[] N=[] f=open('data1.dat','rb') f.seek(0x34) length=struct.unpack("I",f.read(4))[0] print(length) for i in range(length//2): M.append(struct.unpack("H",f.read(2))[0])
f.close() f=open('data2.dat','rb') f.seek(0x34) length=struct.unpack("I",f.read(4))[0] print(length) for i in range(length//2): N.append(struct.unpack("H",f.read(2))[0]) f.close() img = cv.imread('./snow.jpg', 0)/255.0 width=1920 height=1080 ori = cv.imread('./original.jpg', 0)/255.0 FAO = np.fft.fft2(img) FA = np.fft.fft2(ori) alpha=80 G=(FAO-FA)/alpha GG=(FAO-FA)/alpha for i in range(height//2): for j in range(width): GG[M[i]-1][N[j]-1]=G[i][j]
for i in range(height//2): for j in range(width): GG[height-i-1][width-j-1]=GG[i][j] print(GG) GGG=20*(np.real(GG)) plt.imsave('s1.jpg',GGG)