论文复现代码《基于自适应哈夫曼编码的密文可逆信息隐藏算法》调试版

前言

本文展示论文《基于自适应哈夫曼编码的密文可逆信息隐藏算法》的复现代码。代码块的结构如下:

其中,每个代码块都包含了测试该代码块的功能的主函数代码,使用时可放心运行,前提是你按照这个包结构把文件命名改好,放在同一个文件夹下放好。.idea和__pycache__文件不用管。还有main.py、InformationEmbedding.py也是多余的文件。

论文内容解析请参考本人的这篇文章:

论文简述基于自适应哈夫曼编码的密文可逆信息隐藏算法(基于位图压缩的加密图像可逆信息隐藏算法)_zrc007007的博客-CSDN博客

精简版代码在这里:

论文复现代码《基于自适应哈夫曼编码的密文可逆信息隐藏算法》导演剪辑版-CSDN博客

复现代码

MedianEdgeDetector.py

首先是中值预测器,文件名为MedianEdgeDetector.py:

import numpy as npclass MED:def __init__(self):# 示例数据self.data = [[162, 162, 162, 161, 162, 157, 163, 161],[162, 162, 162, 161, 162, 157, 163, 161],[162, 162, 162, 161, 162, 157, 163, 161],[162, 162, 162, 161, 162, 157, 163, 161],[162, 162, 162, 161, 162, 157, 163, 161],[164, 164, 158, 155, 161, 159, 159, 160],[160, 160, 163, 158, 160, 162, 159, 156],[159, 159, 155, 157, 158, 159, 156, 157]]def detect(self, data):# 中值预测result = np.zeros_like(data)result[0][0] = data[0][0]for i in range(1, len(data)):result[i][0] = data[i][0]result[0][i] = data[0][i]for i in range(1, len(data)):for j in range(1, len(data[0])):a = data[i - 1][j - 1]b = data[i - 1][j]c = data[i][j - 1]if a <= min(b, c):result[i][j] = max(b, c)elif a >= max(b, c):result[i][j] = min(b, c)else:result[i][j] = b + c - areturn resultif __name__ == "__main__":print(MED().detect(MED().data))

AdaptiveHuffmanEncoding.py

对图像进行自适应哈夫曼编码,文件名为AdaptiveHuffmanEncoding.py:

from MedianEdgeDetector import MED
import numpy as np
from math import infclass HuffCode:def compare(self, num1, num2):# 比较像素值的相同比特位数count = 0for i in range(8):divisor = pow(2, 7-i)if int(num1 // divisor) == int(num2 // divisor):count += 1num1 = num1 - divisornum2 = num2 - divisorelse:breakreturn countdef count(self, origindata,  data):# 生成图像相同像素值的比特位数的比较结果result = {}resultMap = np.zeros_like(data)resultMap[0][0] = -1for i in range(1, len(data)):resultMap[i][0] = -1resultMap[0][i] = -1for i in range(1, len(data)):for j in range(1, len(data[0])):num = self.compare(origindata[i][j], data[i][j])resultMap[i][j] = numresult[num] = result.get(num, 0) + 1return resultMap, result# 初始化哈夫曼结点
class Huffmannode(object):def __init__(self):self.parent=0self.left=0self.right=0self.weight=0# 选择最小的结点下标
def select_node(huffman):# 俩个结点直接返回不需要找最小俩个结点if len(huffman)==2:return 0,1min=semin=inf# 初始化成无穷大f=s=-1for i in range(len(huffman)):if huffman[i].parent==0:if min>huffman[i].weight:semin=mins=fmin=huffman[i].weightf=ielif semin>huffman[i].weight:semin=huffman[i].weights=ireturn f,s# 编码
def Huffman_code(origin_dict):# 给结点赋权重n=len(origin_dict)m=2*n-1huffman=[]for i in origin_dict:temp_huffmannode=Huffmannode()temp_huffmannode.weight=origin_dict[i]huffman.append(temp_huffmannode)# 构建Huffman树,选择俩个最小的结点合并for i in range(n,m):f,s=select_node(huffman)temp_huffmannode=Huffmannode()temp_huffmannode.weight=huffman[f].weight+huffman[s].weighttemp_huffmannode.right=f  # 小的放在右边temp_huffmannode.left=shuffman[f].parent=huffman[s].parent=ihuffman.append(temp_huffmannode)# 0,1编码,右0,左1codeing_dict = dict.fromkeys(origin_dict, None)for i in range(0,n):s=''k=iparent=huffman[i].parentwhile parent!=0:if huffman[parent].left==k:s+='1'k=parentparent=huffman[parent].parentelse:s+='0'k=parentparent=huffman[parent].parentcodeing_dict[list(origin_dict.keys())[i]]=list(reversed(s))for k in codeing_dict.items():codeing_dict[k[0]] = ''.join(k[1])return codeing_dictif __name__ == "__main__":MED = MED()origindata = MED.dataMEDdata = MED.detect(origindata)print(np.array(origindata))print(MEDdata)print(HuffCode().compare(159, 160))resultMap, result = HuffCode().count(origindata, MEDdata)print(result)'''# 输入原始字符集s = input('输入即将被编码的字符:')# 创建字典计算频率dic = {}for i in range(len(s)):# get方法,如果有键返回该键对应的值,如果没键,可以设置返回值dic[s[i]] = dic.get(s[i], 0) + 1'''code_dict = Huffman_code(result)print(code_dict)

Crypting.py

混沌矩阵加密,文件名为Crypting.py:

import numpy as np
from skimage import io
import matplotlib.pyplot as pltdef crypt(im, miu, x0):'''logistic混沌加密:param im: 图像:param miu: μ参数:param x0: x0参数:return: 返回密文图像'''h, w = im.shapec_ = np.zeros_like(im)c_[0][0] = x0c=[]c.append(x0)result = np.zeros_like(im)result[0][0] = (x0 * pow(2, 48)) % 256for x in range(1, h * w):i = x // wj = x % wc.append(miu * c[x - 1] * (1 - c[x - 1]))c_[i][j] = (c[x] * pow(2, 48)) % 256for i in range(h):for j in range(w):result[i][j] = im[i][j] ^ c_[i][j]return resultdef transform(img):column, row = img.shaperesult = np.zeros_like(img, dtype='int_')for i in range(column):for j in range(row):result[i][j] = int(img[i][j] * 255)return resultif __name__ == "__main__":plt.set_cmap(cmap='gray')img = io.imread("../img/lena_grey.tif")print(img)plt.imshow(img)img = transform(img)print(img)plt.figure()enc_img = crypt(img, 3.6, 0.5)plt.imshow(enc_img)plt.figure()dec_img = crypt(enc_img, 3.6, 0.5)plt.imshow(dec_img)plt.show()

LabelMapEmbedding.py

位图嵌入,文件名LabelMapEmbedding.py:

import numpy as np
import math
from AdaptiveHuffmanEncoding import *
from Crypting import *
# from MedianEdgeDetector import *def int2bin(num, leng):'''整数int转二进制格式binTransform a integer to a string whose length is leng.:param num: numbers waiting for transforming:param leng: the length of hoped result string:return: a string of leng length'''if leng < 1:raise Exception("Length isn't positive integer!")place = 1result = ''while place <= leng:result = str(num % 2) + resultnum = num // 2if num == 0:return (leng - place) * '0' + resultplace += 1raise Exception("Length of binary string isn't enough!")def bin2int(string, leng):'''二进制格式bin转整数intTransfer a string of length of leng to a positive integer:param string: string waiting to be transferred:param leng: the length of reading:return: a positive integer less than 2^leng'''if leng < 1:raise Exception("Length isn't positive integer!")if len(string) < leng:raise Exception("Length of string under transferring isn't enough!")place = 1result = 0while place <= leng:result += int(string[place - 1]) * pow(2, leng - place)place += 1return resultdef binstrcomplmt(string, length, complement):'''给二进制格式补位,补到前面。比如补0就给complement传0,补1就传1Complement strings with which we decide.:param string: string waiting to be complemented:param length: what we hope it to length:param complement: using what character to complement it:return: string already complemented'''return (length - len(string)) * complement + stringdef binstrbackcomplmt(string, length, complement):'''给二进制格式补位,补到后面Complement strings with which we decide on its backhand.:param string: string waiting to be complemented:param length: what we hope it to length:param complement: using what character to complement it:return: string already complemented'''return string + (length - len(string)) * complementdef generatec(dict):'''生成嵌入信息中的c1到c8generate c info:param dict: Huffman code diction:return:'''result = ''c = []for i in range(9):c.append(0)c[i] = len(dict.get(i, ''))result += int2bin(c[i], 4)print(c)return resultdef generateh(dict):'''生成嵌入信息中的h1到h8generate h info:param dict: Huffman code diction:return:'''result = ''h = []for i in range(9):h.append('')h[i] = binstrcomplmt(dict.get(i, '0'), 8, '0')result += h[i]print(h)return resultdef countLm(countDict, lenDict):'''生成论文中说的Lm,变成Eta还需要转换一下Counting Lm:param countDict: diction of Huffman codes' appearance:param lenDict: Huffman code diction:return:'''count = 0for i in range(9):count += countDict.get(i, 0) * len(lenDict.get(i, ''))return countdef generatef(Lm, shapeOfImg):'''生成嵌入信息中的fgenerate f, which is Lm's bits' num's binary format:param Lm::param shapeOfImg::return:'''return int2bin(Lm, math.ceil(np.log2(shapeOfImg[0])) + math.ceil(np.log2(shapeOfImg[1])) + 2)def generateEta(dic, labelmap):'''生成嵌入信息中的EtaTransferred label map's binary format:param dic::param labelmap::return:'''result = ''for i in range(1, labelmap.shape[0]):for j in range(1, labelmap.shape[1]):result += dic[labelmap[i][j]]return resultdef generatelabelinfo(HuffDict, CountDict, LabelMap):'''生成总的嵌入信息Generate embedding information of label map:param HuffDict: Huffman code diction:param CountDict: Length of Huffman codes' diction:param LabelMap: The label map:return: Embedding information of label map'''return generatec(HuffDict) + generateh(HuffDict) + generatef(countLm(CountDict,HuffDict), LabelMap.shape)\+ generateEta(HuffDict, LabelMap)def embedinfo(LabelInfo, EncryptedImg, LabelMap, data):# 嵌入位图信息ReferencePixels = ''result = np.array(EncryptedImg)for i in range(EncryptedImg.shape[0]):ReferencePixels += int2bin(EncryptedImg[0][i], 8)result[0][i] = bin2int(LabelInfo, 8)LabelInfo = LabelInfo[8:]  # 截掉8个for i in range(1, EncryptedImg.shape[1]):ReferencePixels += int2bin(EncryptedImg[i][0], 8)result[i][0] = bin2int(LabelInfo, 8)LabelInfo = LabelInfo[8:]EmbeddingInfo = LabelInfo + ReferencePixels + dataprint("Length of Reference Pixels is:", len(ReferencePixels))count = 0row = count // (EncryptedImg.shape[1] - 1) + 1column = count % (EncryptedImg.shape[1] - 1) + 1t = LabelMap[row][column]maximum = (EncryptedImg.shape[0] - 1) * (EncryptedImg.shape[1] - 1)while len(EmbeddingInfo) > 0:if 0 <= t <= 6:result[row][column] = EncryptedImg[row][column] % pow(2, 7 - t)\+ bin2int(binstrbackcomplmt(EmbeddingInfo[:t+1], 8, '0'), 8)EmbeddingInfo = EmbeddingInfo[t+1:]elif 7 <= t <= 8:result[row][column] = bin2int(binstrbackcomplmt(EmbeddingInfo[:8], 8, '0'), 8)EmbeddingInfo = EmbeddingInfo[8:]count += 1if count >= maximum:raise Exception("There's no room for embedding!")row = count // (EncryptedImg.shape[1] - 1) + 1column = count % (EncryptedImg.shape[1] - 1) + 1t = LabelMap[row][column]return resultdef detect(data):'''测试用预测函数:param data::return:'''result = np.zeros_like(data)result[0][0] = data[0][0]for i in range(1, len(data)):result[i][0] = data[i][0]result[0][i] = data[0][i]for i in range(1, len(data)):for j in range(1, len(data[0])):a = data[i - 1][j - 1]b = data[i - 1][j]c = data[i][j - 1]if a <= min(b, c):result[i][j] = max(b, c)elif a >= max(b, c):result[i][j] = min(b, c)else:result[i][j] = b + c - areturn resultif __name__ == "__main__":print(128//2)print(128%2)strng = int2bin(1, 8)print(strng)print(bin2int(strng,8))print(bin2int('1', 1))MED = MED()origindata = MED.dataorigindata = np.array(origindata)MEDdata = MED.detect(origindata)print("The origin data is:")print(np.array(origindata))print("The predicted data is:")print(MEDdata)print(HuffCode().compare(159, 160))resultMap, countingResult = HuffCode().count(origindata, MEDdata)print("The label map is:")print(resultMap)print("The counting result of Huffman coding is:", countingResult)'''# 输入原始字符集s = input('输入即将被编码的字符:')# 创建字典计算频率dic = {}for i in range(len(s)):# get方法,如果有键返回该键对应的值,如果没键,可以设置返回值dic[s[i]] = dic.get(s[i], 0) + 1'''code_dict = Huffman_code(countingResult)print(code_dict)generatec(code_dict)print(generatec(code_dict))print(len(generatec(code_dict)))print(generateh(code_dict), len(generateh(code_dict)))lm = countLm(countingResult, code_dict)print("Lm is:", lm)f = generatef(lm, MEDdata.shape)print("f is:", f)print("length of f is:", len(f))Eta = generateEta(code_dict, resultMap)print("The length of Eta is:", len(Eta))print("Eta is:")print(Eta)labelInfo = generatelabelinfo(code_dict,countingResult, resultMap)print("The length of labelInfo is:", len(labelInfo))print("Label info:")print(labelInfo)print("Is length of c, h, f and Eta equals to labelInfo:", len(generatec(code_dict)) + len(generateh(code_dict)) +\len(f) + len(Eta) == len(labelInfo))embedded = embedinfo(labelInfo, crypt(origindata, 3.6, 0.5), resultMap, '0110')print(embedded)strng = int2bin(903, 11)print(strng)print(strng[12:] == '')print(strng[:3])print(detect(origindata))

DataExtractionandImageRecovery.py

数据提取和恢复,文件名DataExtractionandImageRecovery.py:

from LabelMapEmbedding import *
from skimage import io
import matplotlib.pyplot as pltdef HuffDecode(HuffDict, info):# 哈夫曼解码for i in range(9):if info[:len(HuffDict.get(i, ''))] == HuffDict.get(i, -1):print("The i is:", i)print(info[:8])print(HuffDict)return i, len(HuffDict[i])raise Exception("No string matches!")def extractpixel(pixel, t):# 根据t值,恢复像素位数if 0 <= t <= 7:return int2bin(pixel, 8)[:t+1]elif t == 8:return int2bin(pixel, 8)else:raise Exception("T out of range!")def calctcut(t):# 根据t值,返回像素数if 0 <= t <= 7:return t + 1elif t == 8:return 8else:raise Exception("T out of range!")def extract1(encrypted):# 提取第一行、第一列info = ''LenDict = {}HuffDict = {}for i in range(encrypted.shape[0]):info += int2bin(encrypted[0][i], 8)for i in range(1, encrypted.shape[1]):info += int2bin(encrypted[i][0], 8)for i in range(9):LenDict[i] = bin2int(info[:4], 4)info = info[4:]for i in range(9):if LenDict[i] != 0:HuffDict[i] = info[8-LenDict[i]:8]info = info[8:]print(LenDict, HuffDict)return HuffDict, infodef extract_exp(encrypted, HuffDict, info, datalen, Label):  # Label是用来测试位图和算出来的是不是一样的,可以删掉# 提取位图LabelMap = np.zeros_like(encrypted)decrypted1 = np.array(encrypted)LmLen = math.ceil(np.log2(encrypted.shape[0])) + math.ceil(np.log2(encrypted.shape[1])) + 2Lm = bin2int(info[:LmLen], LmLen)info = info[LmLen:]infoLen = Lm + ((encrypted.shape[0] - 1) + (encrypted.shape[1] - 1) - 1) * 8 + datalencount = len(info)  # 已提取到的信息长度place = 0pursuit = 0gonext = 0count1 = 1while count < infoLen:print("count:", count)print("Info len:", infoLen)print("pursuit:", pursuit)row = place // (encrypted.shape[1] - 1) + 1column = place % (encrypted.shape[1] - 1) + 1print("origin row, column:", row, column)if count1 == 1 and count < Lm:t, CodeLen = HuffDecode(HuffDict, info)print("t is:", t)LabelMap[row][column] = tinfo = info[CodeLen:] + extractpixel(encrypted[row][column], t)count += calctcut(t)place += 1print("step1")print("Is the Label Map equal to the extrated one:", Label[row][column] == t)print("place is:", place)print("count is:", count)else:pursuit = 1count1 = 0if pursuit == 1 and gonext == 0:record = placeprint("\nThe staring of step 2's row and column is:\n", row , column)while place < (encrypted.shape[0] - 1) * (encrypted.shape[1] - 1):row = place // (encrypted.shape[1] - 1) + 1column = place % (encrypted.shape[1] - 1) + 1t, CodeLen = HuffDecode(HuffDict, info)LabelMap[row][column] = tinfo = info[CodeLen:] + extractpixel(encrypted[row][column], t)print("step2")print("Is the Label Map equal to the extrated one:", Label[row][column] == t)print("T is {}, and the Label is {}".format(t, Label[row][column]))print("place:", place)print("row, column:", row, column)place += 1print('haha',place)print("end")place = recordrow = place // (encrypted.shape[1] - 1) + 1column = place % (encrypted.shape[1] - 1) + 1gonext = 1if gonext == 1 and count - Lm < (encrypted.shape[0] - 1) * (encrypted.shape[1] - 1) * 8 + datalen:# print("place:",place)# print("row, column:", row, column)info += extractpixel(encrypted[row][column], LabelMap[row][column])count += calctcut(LabelMap[row][column])# print("infolen:", infoLen)# print("count:", count)# print()place += 1for i in range(encrypted.shape[0]):LabelMap[0][i] = -1decrypted1[0][i] = bin2int(info[:8], 8)info = info[8:]for i in range(1, encrypted.shape[1]):LabelMap[i][0] = -1decrypted1[i][0] = bin2int(info[:8], 8)info = info[8:]data = info[:datalen]return LabelMap, decrypted1, datadef reverse(char):# 反转0和1if char == '0':return '1'elif char == '1':return '0'else:raise Exception("Not 0 or 1!")def detect(data, i, j):'''测试用预测函数:param data::return:'''a = data[i - 1][j - 1]b = data[i - 1][j]c = data[i][j - 1]if a <= min(b, c):result = max(b, c)elif a >= max(b, c):result = min(b, c)else:result = b + c - areturn resultdef recovery(img, LabelMap):# 恢复图像result = np.zeros_like(img)for i in range(img.shape[0]):result[0][i] = img[0][i]for i in range(1, img.shape[1]):result[i][0] = img[i][0]for i in range(1, img.shape[0]):for j in range(1, img.shape[1]):px = detect(result, i, j)t = LabelMap[i][j]if t == 8:result[i][j] = pxelif 0 <= t <= 7:result[i][j] = bin2int(int2bin(px, 8)[:t] + '0' * (8 - t), 8)\+ int(reverse(int2bin(px, 8)[t:t+1])) * pow(2, 7 - t) + img[i][j] % pow(2, 7 - t)else:raise Exception("T out of range!")return resultif __name__ == "__main__":MED = MED()# origindata = MED.dataorigindata = io.imread("../img/lena_grey.tif")origindata = transform(origindata)origindata = np.array(origindata)MEDdata = MED.detect(origindata)print("The origin data is:")print(np.array(origindata))print("The predicted data is:")print(MEDdata)print(HuffCode().compare(159, 160))resultMap, countingResult = HuffCode().count(origindata, MEDdata)print("The label map is:")print(resultMap)print("The counting result of Huffman coding is:", countingResult)code_dict = Huffman_code(countingResult)print(code_dict)generatec(code_dict)print(generatec(code_dict))print(len(generatec(code_dict)))print(generateh(code_dict), len(generateh(code_dict)))lm = countLm(countingResult, code_dict)print("Lm is:", lm)f = generatef(lm, MEDdata.shape)print("f is:", f)print("length of f is:", len(f))Eta = generateEta(code_dict, resultMap)print("The length of Eta is:", len(Eta))print("Eta is:")print(Eta)labelInfo = generatelabelinfo(code_dict,countingResult, resultMap)print("The length of labelInfo is:", len(labelInfo))print("Label info:")print(labelInfo)secret = '0110010000' * 50  # 用于测试的秘密信息embedded = embedinfo(labelInfo, crypt(origindata, 3.6, 0.5), resultMap, secret)  # 嵌入秘密信息print(embedded)huff_code, info1 = extract1(embedded)print("The length of rest of info waiting for extracting is:", len(info1))print(int2bin(100, 8))print(extractpixel(100, 0))# resultMap2, decrypted1, data= extract2(embedded, huff_code, info1, 4)resultMap2, decrypted1, data = extract_exp(embedded, huff_code, info1, len(secret), resultMap)print("The encrypted img is:\n", crypt(origindata, 3.6, 0.5))print("The decrypted1 img is:\n", decrypted1)print(resultMap2)print(resultMap)print(data)if secret == data:print("THE extract is successful!")img1 = crypt(decrypted1, 3.6, 0.5)print("img1 is:\n",img1)'''print("Origin:")print(origindata)print("Detect img:")print(detect(img1))print("Detected origin data:")print(detect(origindata))'''res = img1 - origindataprint("result compare with origin data:\n")print(res)img2 = recovery(img1, resultMap2)print(img2)res = img2 - origindataprint("img2 compares to origin:\n", res)plt.set_cmap(cmap='gray')plt.subplot(221)plt.imshow(origindata)plt.title("Origin imagery")plt.subplot(222)plt.imshow(embedded)plt.title("Embedded imagery")plt.subplot(223)plt.imshow(img1)plt.title("Preliminary decrypted imagine")plt.subplot(224)plt.imshow(img2)plt.title("Fully recovered imagine")plt.show()

Comparison.py

计算指标,比较结果,文件名Comparison.py:

import numpy as np
import math
import cv2
from DataExtractionandImageRecovery import *
from skimage.color import rgb2graydef ssim(img1, img2):#计算ssim指标C1 = (0.01 * 255)**2C2 = (0.03 * 255)**2img1 = img1.astype(np.float64)img2 = img2.astype(np.float64)kernel = cv2.getGaussianKernel(11, 1.5)window = np.outer(kernel, kernel.transpose())mu1 = cv2.filter2D(img1, -1, window)[5:-5, 5:-5] # validmu2 = cv2.filter2D(img2, -1, window)[5:-5, 5:-5]mu1_sq = mu1**2mu2_sq = mu2**2mu1_mu2 = mu1 * mu2sigma1_sq = cv2.filter2D(img1**2, -1, window)[5:-5, 5:-5] - mu1_sqsigma2_sq = cv2.filter2D(img2**2, -1, window)[5:-5, 5:-5] - mu2_sqsigma12 = cv2.filter2D(img1 * img2, -1, window)[5:-5, 5:-5] - mu1_mu2ssim_map = ((2 * mu1_mu2 + C1) * (2 * sigma12 + C2)) / ((mu1_sq + mu2_sq + C1) *(sigma1_sq + sigma2_sq + C2))return ssim_map.mean()def psnr(img1, img2):# 计算PSNR指标mse = np.mean( (img1/255. - img2/255.) ** 2 )if mse < 1.0e-10:return 100PIXEL_MAX = 1return 20 * math.log10(PIXEL_MAX / math.sqrt(mse))if __name__ == "__main__":MED = MED()# Baboon 3.6 0.5origindata = io.imread("../img/lena_gray_512.tif")# origindata = rgb2gray(origindata)print(origindata)# origindata = transform(origindata)origindata = np.array(origindata)MEDdata = MED.detect(origindata)resultMap, countingResult = HuffCode().count(origindata, MEDdata)code_dict = Huffman_code(countingResult)labelInfo = generatelabelinfo(code_dict, countingResult, resultMap)encrypted = crypt(origindata, 3.7, 0.9)containingLabel = embedinfo(labelInfo, encrypted, resultMap, '')embedded = embedinfo(labelInfo, encrypted, resultMap, '0110010000')huff_code, info1 = extract1(embedded)# resultMap2, decrypted1, data = extract_exp(embedded, huff_code, info1, 10, resultMap)# img1 = crypt(decrypted1, 3.6, 0.5)print("Lena")print("Comparison of PSNR and SSIM between encrypted imagine and the original:")print("PSNR:", psnr(origindata, encrypted))print("SSIM:", ssim(origindata, encrypted))print()print("Comparison of PSNR and SSIM between containing Label Map imagine and the original:")print("PSNR:", psnr(origindata, containingLabel))print("SSIM:", ssim(origindata, containingLabel))print()print("Comparison of PSNR and SSIM between embedded imagine and the original:")print("(With the secret of '0110010000')")print("PSNR:", psnr(origindata, embedded))print("SSIM:", ssim(origindata, embedded))

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/184951.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

重载、重写、重定义的辨析

C重载、重写、重定义 重载、重写、重定义对比一、重载&#xff08;overload&#xff09;二、重写 / 覆盖&#xff08;override&#xff09;三、重定义 / 隐藏&#xff08;redefining&#xff09; * 为什么在虚函数中不能使用 static 关键字&#xff1f;动态绑定&#xff08;Dyn…

YOLOv5轻量化改进之MobileNetv3

目录 一、原理 二、代码 三、应用到YOLOv5 一、原理 我们提出了基于互补搜索技术和新颖架构设计相结合的下一代mobilenet。MobileNetV3通过硬件网络架构搜索(NAS)和NetAdapt算法的结合来调整到移动电话cpu,然后通过新的架构进步进行改进。本文开始探索自动搜索算法和网络设计…

map文件解析

Map文件内容分为以下五段&#xff1a; 1&#xff09;Section Cross References&#xff1a;模块、段(入口)交叉引用&#xff1b;(ASR编译生成的map文件没有输出该段信息) 2&#xff09;Removing Unused input sections from the image&#xff1a;移除未使用的模块&#xff1…

App测试中iOS和Android的差异

1、系统版本&#xff1a; iOS和Android系统版本的更新速度、使用人数比例以及功能的不同都可能导致应用程序在不同操作系统版本上的表现和兼容性存在区别。 例如&#xff0c;在iOS平台上&#xff0c;很多用户会更快地升级到最新版本的iOS系统&#xff0c;而在Android平台上&a…

智慧灯杆网关:引领城市智慧照明的未来

智慧灯杆网关&#xff0c;作为城市智慧照明系统的核心组件&#xff0c;正逐渐成为各大城市发展的关键所在。它的出现使得城市照明管理更加智能、高效&#xff0c;为未来城市的可持续发展奠定了坚实的基础。 智慧灯杆网关是一种集网络通信、数据处理、远程控制等功能于一体的设备…

一款适用于船载、化工园区、工厂的防水LoRa网关推荐

工业网关的实践应用场景非常广泛&#xff0c;比如&#xff1a;工业现场PLC、变频器、机器人等设备的远程维护&#xff1b;工程机械的远程维护和管理&#xff1b;车间设备与工艺系统的远程维护和管理&#xff1b;小区二次供水水泵的远程监测及控制&#xff1b;油气田和油井等现场…

Elk+Filebeat+Kafka实现日志收集

ElkFilebeatKafka实现日志收集(本机nginx) 部署Zookeeper 1.实验组件 #准备3台服务器做Zookeeper集群 20.0.0.10 20.0.0.20 20.0.0.30 2.安装前准备 #关闭防火墙 systemctl stop firewalld systemctl disable firewalld setenforce 0#安装JDK yum install -y java-1.8.0-o…

springboot启动开启热部署

springboot启动开启热部署 手动方式 或者点idea上面的build->build project 自动方式 勾上Build project automatically 然后ctrl alt shift / 选择Registr 勾上就好了 新版idea可以在这里选 热部署范围设置 这是spring-boot-devtools起的作用&#xff0c;所以还…

VMware虚拟机安装和使用教程(附最新安装包+以ubuntu为例子讲解)

目录 一、VMware Workstation 17 Pro 简介 二、新功能与改进 三、安装教程 3.1、下载安装包 3.2、运行安装包 四、创建虚拟机 五、启动虚拟机 六、总结与展望 一、VMware Workstation 17 Pro 简介 VMware Workstation 17 Pro是VMware公司为专业用户打造的一款虚拟化软件…

echarts x轴y轴添加单位

function evaluationDistributionBar(data,id) { //data.series[0].data [1,31,1,1]//data.series[1].data [1,1,1,1]if(!data || data.series.length 0) returnfor(let i in data.series){//给柱状图动态修改颜色if(data.series[i].name 男){data.series[i].itemStyle {c…

分享5款靠谱好用,无广告不流氓的好软件

​ 话不多说&#xff0c;直入正题&#xff0c;全都是靠谱好用&#xff0c;无广告不流氓的好软件&#xff0c;可以先点赞收藏&#xff0c;以后慢慢用。 1.动态壁纸软件——Lively Wallpaper ​ Lively Wallpaper是一款可以将视频、GIF、网页、游戏等内容作为桌面壁纸的软件&am…

XC1136 功率传输(PD) Sink控制器IC PD诱骗器芯片 输出可调 可支持多个

XC1136是一款功率传输(PD) Sink控制器IC。XC1136可以从符合Type-CPD协议的电源中请求最大或指定电压。输入电压范围:3V~28V支持USBType-C规范版本1.3支持USB PD2.0和PD3.0通讯协议&#xff0c;最多支持七个电源对象 该XC1136内置拉低电阻CC1和CC2引脚。当XC1136连接到T…

Java —— ArrayList与顺序表

目录 1. 线性表 2. 顺序表 接口的实现 3. ArrayList简介 3.1 ArrayList介绍 3.2 ArrayList的构造方法 4. ArrayList的扩容机制 5. ArrayList的常见操作 6. ArrayList的遍历 7. 例题 8. ArrayList的具体使用 8.1 简单的洗牌算法 8.2 杨辉三角 9. ArrayList的问题及思考 1. 线性表…

“Install Js dependencies failed“JS SDK安装失败【Bug已解决-鸿蒙开发】

文章目录 项目场景:问题描述原因分析:解决方案:解决措施1解决方案2:其他解决方案解决方案3:此Bug解决方案总结项目场景: 在下载JS SDK时,出现下载失败的情况,并显示“Install Js dependencies failed”。 在使用版本为DevEco Studio 3.0.0.601 Beta1进行低代码开发时…

世微 低功耗 PFM DC-DC 升压芯片 AP8105 干电池手持设备驱动IC

概述 AP8105 系列产品是一种高效率、低纹波、工作频率高的 PFM 升压 DC-DC 变换器。AP8105 系列产品仅需要四个外围元器件&#xff0c;就可完成将低输入的电池电压变换升压到所需的工作电压&#xff0c;非常适合于便携式 1&#xff5e;4 节普通电池应用的场合。电路采用了高性能…

mybatis快速入门(基于Mapper接口编程)

1、准备数据模型&#xff0c;建库建表 CREATE DATABASE mybatis-example;USE mybatis-example;CREATE TABLE t_emp(emp_id INT AUTO_INCREMENT,emp_name CHAR(100),emp_salary DOUBLE(10,5),PRIMARY KEY(emp_id) );INSERT INTO t_emp(emp_name,emp_salary) VALUES("tom&qu…

测试相关-面试高频

测试面试相关 面试 测试的具体场景 功能测试 具体的测试工具Jmeter Postman selenium pytest 怎么看待测试的潜力与挑战 软件测试是正在快速发展&#xff0c;充满挑战的领域。尽管现在许多自动化测试软件的出现使得传统手工测试的方式被代替&#xff0c;但自动化测试工具的…

低功耗无线SOC芯片Si24R03

Si24R03是一款高度集成的低功耗无线SOC芯片&#xff0c;芯片为QFN32 5x5mm封装&#xff0c;集成了资源丰富的MCU内核与2.4G收发器模块&#xff0c;最低功耗可达1.6uA&#xff0c;极少外围器件&#xff0c;大幅降低系统应用成本&#xff0c;同时配套有成熟的开发调试软件和丰富的…

Oracle SQL优化

1、书写顺序和执行顺序 在Oracle SQL中&#xff0c;查询的书写顺序和执行顺序是不同的。 1.1SQL书写顺序如下&#xff1a; SELECTFROMWHEREGROUP BYHAVINGORDER BY 1.2 SQL执行顺序 FROM&#xff1a;数据源被确定&#xff0c;表连接操作也在此步骤完成。 WHERE&#xff1a;对…

MySQL进阶知识:SQL性能优化

目录 SQL性能分析 SQL执行频率 慢查询日志 profile详情 explain执行计划 索引的使用 最左前缀法则 范围查询 索引列运算 字符串加引号 模糊查询 or连接的条件 数据分布影响 SQL提示 覆盖索引 前缀索引 索引设计原则 SQL优化 insert优化 主键优化 页分裂 …