⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ss_pnf.m

📁 matlab code for spread spectrumusing M george algo
💻 M
字号:
function [r1] = ss_pnf(r,s ,ALPHA )

%% ALPHA=embedding strength
%% r= HOST gray image
%% s= BINARY LOGO to be watermarked
%% r1= WATERMARKED image
%% PN SEQUENCE GENERATOR ALGORITHM on spatial domain

%clc;
if (nargin == 2)
   ALPHA=1;
end

r=double(r);
[rowr colr]=size(r);
tot_no_pixel_host=rowr*colr;
r1=r;


[rows cols]=size(s);
tot_no_pixel_logo=rows*cols;
a=zeros(1,tot_no_pixel_logo);
k=1;
for i=1:rows
    for j=1:cols
        if s(i,j)>127
            a(1,k)=1;
        else
            a(1,k)=-1;
        end
        k=k+1;
    end
end
%pause      
        

chip_rate=floor(tot_no_pixel_host/tot_no_pixel_logo);
pn_seq=ones(1,chip_rate);
temp1=mlbs_ch(floor(log2(chip_rate)));
temp1=temp1';
[rowtmp coltmp]=size(temp1);
pn_seq(1,1:coltmp)=temp1(1,1:coltmp);


rt=r';
rt=rt(:)';

w=rt;%zeros(1,tot_no_pixel_host);
b=ones(1, tot_no_pixel_host);
k=1;
for i=1:chip_rate:tot_no_pixel_logo*chip_rate
    %b(1:1,i:i+chip_rate-1)=repmat(a(k),1,chip_rate);
    %w(1:1,i:i+chip_rate-1)=(ALPHA*b(1:1,i:i+chip_rate-1))*pn_seq(1:1,1:chip_rate)';
    w(1:1,i:i+chip_rate-1)=(ALPHA*a(k))*pn_seq(1:1,1:chip_rate);
    k=k+1;
end

%tot_no_pixel_host
rt(1:tot_no_pixel_host)=rt(1:tot_no_pixel_host)+w(1:tot_no_pixel_host) ;%%% SPATIAL EMBEDDING 
k=1;
%size(rt)
rx=zeros(rowr,colr);
for i=1:rowr
    for j=1:colr
        rx(i,j)=rt(1,k);
        k=k+1;
    end
end
r1=rx;
clear rx
r1=uint8(r1);
%imshow(r1)
x=num2str(ALPHA);
str1=num2str(rowr);
str2=num2str(colr);
str3=num2str(rows);
str4=num2str(cols);
strf=strcat('pn_emb_',str1,'x',str2,'host_',str3,'x',str4,'alpha_',x,'logo.bmp');

imwrite(r1,strf);




    

⌨️ 快捷键说明

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