sswm.m

来自「cox方法展频水印matlab源码」· M 代码 · 共 43 行

M
43
字号
clear; close all;
N = 10000;
alfa = 0.1;
Ig = imread('monarchgray.bmp');
%imshow(I);
% I = double(I);
% Ig = 0.3*I(:,:,1) + 0.59*I(:,:,2) + 0.11*I(:,:,3);
% Ig = uint8(Ig);

% imwrite(Ig,'monarchgray.bmp')
% figure; imshow(Ig);
Ig = double(Ig);

dctIg = dct2(Ig);
%figure;imshow(log(abs(dctIg)),[]), colormap(jet), colorbar

nRow = size(dctIg,1);
nCol = size(dctIg,2);

adctIg = abs(dctIg);
[sdctIg,ind] = sort(adctIg(:));
%ssdctIg = ssdctIg(end-N:end-1);

W = randn(N,1);

for i=1:1:N
    pt = ind(end-i);
    indCol = ceil(pt/nRow);
    indRow = mod(pt,nRow);
    if indRow == 0
        indRow = nRow;
    end
    dctIg(indRow,indCol) = dctIg(indRow,indCol)*(1+alfa*W(i)); 
end

Igstego = idct2(dctIg);
figure; imshow(Igstego,[]);

imwrite(uint8(Igstego),'monarchgraystego.bmp');
   
    
    
    

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?