我的想法是首先使用dwt2分解图像,然后将dct2应用于coefficients_approximation,在结果上应用水印,然后重新组合图像。
final_image = idwt2( idct2 ( dct2 ( dwt2 (starting_image))))但是每当我这样做的时候,我就会失去很多质量,我不知道为什么。这是代码,你知道吗?
clear all; clc;
% read lena img
lena = double(imread('lena.jpg'));
% read watermark img
%w = imread('mark.png');
load cookiebears.mat
% compure DWT on lena and watermark
[approximate_lena, horizontal_lena, vertical_lena, diagonal_lena] = dwt2(lena, 'haar');
% i have to save the image first and then open it in order to use it in
% dct2() omitting this step generate an error
imwrite(uint8(approximate_lena), 'ca_lena.jpg');
% read approximate_lena layer in a variable
lena_ca = double(imread('ca_lena.jpg'));
% perform DCT on approximation level of lena picture
dct_lena = dct2(lena_ca);
% embed the watermark into dct_lena
% insert here function to embed the watermark
% dct_lena = insert_watermark();
% now I can recompose the lena coefficients approximation
lena_ca_recomposed = idct2(dct_lena);
% recompose DWT
lena_recomposed = idwt2(lena_ca_recomposed, horizontal_lena,vertical_lena, diagonal_lena, 'haar');正如你在下面看到的:在第一行中,我们的开始图片在左边,结果图片在右边(它的颜色更深,细节更少)。在左边的第二行中,我们比较了原始图像上的dwt2之后的CA和右边用idct2重组的CA

发布于 2020-10-19 15:42:12
该问题是由于将图像保存到文件并再次读取而导致的。我删除了以下行:
imwrite(uint8(approximate_lena), 'ca_lena.jpg');和
lena_ca = double(imread('ca_lena.jpg'));现在它可以工作了
https://stackoverflow.com/questions/64379114
复制相似问题