matlab数字水印lsb方法 100

%readimagemat=imread('1.jpg');mbt=imread('2.bmp');imgread=rgb2gray(mat);mbt=uint8(mbt... % read image
mat = imread('1.jpg');
mbt = imread('2.bmp');
imgread = rgb2gray(mat);
mbt = uint8(mbt);
[maa,mab] = size(imgread); %[mba,mbb] = size(mbt); md = ones(maa,mab);
ma = zeros(2*maa,2*mab); ma = im2uint8(ma);

% progress the image
for i=1:1:maa

for j=1:1:mab

imgread(i,j)=imgread(i,j)-mod(imgread(i,j),4);
end
end

%========================
%enlarge image

%=======================
for j=1:1:mab
for i=1:1:maa

ma(2*i-1,2*j-1) = imgread(i,j); ma(2*i,2*j-1) = imgread(i,j); ma(2*i-1,2*j) = imgread(i,j);

ma(2*i,2*j) = imgread(i,j); mb(2*i-1,2*j-1) = mbt(i,j); mb(2*i,2*j-1) = mbt(i,j); mb(2*i-1,2*j) = mbt(i,j);

mb(2*i,2*j) = mbt(i,j);
end
end

ma = ma+mb*3;
%ma = ma-mb*3;
%=======================
% attack

%=======================

noise = normrnd(0,0.2,2*maa,2*mab); %Gaussian, uniform,

% laplace,salt-pepper
%ma = double(ma); ma = ma+ noise; ma = uint8(ma); figure(1);

subplot(2,2,1);imshow(imgread); subplot(2,2,2);imshow(mbt,[0,1]); subplot(2,2,3);imshow(ma);subplot(2,2,4);imshow(noise)%

%subplot(2,2,1);imshow(mb,[0,1]);subplot(2,2,2);imshow(ma);subplot(2,2,3);imshow(mc);

%=======================
% watermark extraction
%=======================
for i=1:1:maa

for j=1:1:mab

a=mod(ma(2*i-1,2*j-1),2)+mod(ma(2*i,2*j-1),2)+mod(ma(2*i-1,2*j),2)+mod(ma(2*i,2*j),2);

a=(-a+mod(ma(2*i-1,2*j-1),4)+mod(ma(2*i,2*j-1),4)+mod(ma(2*i-1,2*j),4)+mod(ma(2*i,2*j),4))/2;

if a<4

md(i,j)=0;
else
md(i,j)=1;
end
end
end

md = uint8(md);
figure(2);imshow(md,[0,1]);
求大神给讲讲这段程序啥意思 高分
展开
 我来答
我行我素850915
2014-05-22 · TA获得超过8241个赞
知道大有可为答主
回答量:5788
采纳率:77%
帮助的人:1797万
展开全部
% read image
mat = imread('1.jpg');
mba = imread('2.bmp');
imgread = rgb2gray(mat);
mbt=imresize(mba,size(imgread));
mbt = uint8(mbt);
[maa,mab] = size(imgread);
[mba,mbb] = size(mbt);
md = ones(maa,mab);
ma = zeros(2*maa,2*mab);
ma = im2uint8(ma);

% progress the image
for i=1:1:maa

for j=1:1:mab

imgread(i,j)=imgread(i,j)-mod(imgread(i,j),4);
end
end

%========================
%enlarge image

%=======================
for j=1:1:mab
for i=1:1:maa

ma(2*i-1,2*j-1) = imgread(i,j);
ma(2*i,2*j-1) = imgread(i,j);
ma(2*i-1,2*j) = imgread(i,j);

ma(2*i,2*j) = imgread(i,j);
mb(2*i-1,2*j-1) = mbt(i,j);
mb(2*i,2*j-1) = mbt(i,j);
mb(2*i-1,2*j) = mbt(i,j);

mb(2*i,2*j) = mbt(i,j);
end
end

ma = ma+mb*3;
%ma = ma-mb*3;
%=======================
% attack

%=======================

noise = normrnd(0,0.2,2*maa,2*mab); %Gaussian, uniform,

% laplace,salt-pepper
ma = double(ma);
ma = ma+ noise;
ma = uint8(ma);
figure(1);

subplot(2,2,1);imshow(imgread);
subplot(2,2,2);imshow(mbt,[0,1]);
subplot(2,2,3);imshow(ma);
subplot(2,2,4);imshow(noise)%

%subplot(2,2,1);imshow(mb,[0,1]);subplot(2,2,2);imshow(ma);subplot(2,2,3);imshow(mc);

%=======================
% watermark extraction
%=======================
for i=1:1:maa

for j=1:1:mab

a=mod(ma(2*i-1,2*j-1),2)+mod(ma(2*i,2*j-1),2)+mod(ma(2*i-1,2*j),2)+mod(ma(2*i,2*j),2);

a=(-a+mod(ma(2*i-1,2*j-1),4)+mod(ma(2*i,2*j-1),4)+mod(ma(2*i-1,2*j),4)+mod(ma(2*i,2*j),4))/2;

if a<4

md(i,j)=0;
else
md(i,j)=1;
end
end
end

md = uint8(md);
figure(2);imshow(md,[0,1]);
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
博思aippt
2024-07-20 广告
博思AIPPT是基于ai制作PPT的智能在线工具,它提供了4种AI制作PPT的方式,包括AI生成大纲、AI直接生成PPT、文本生成PPT、AI提炼文档生成PPT,一站式集成多种AI生成PPT的方式,可满足办公用户的不同需求和使用场景。ai生... 点击进入详情页
本回答由博思aippt提供
笑知亿3
推荐于2016-02-16 · TA获得超过1.1万个赞
知道小有建树答主
回答量:1396
采纳率:72%
帮助的人:307万
展开全部
% read image
mat = imread('1.jpg');
mba = imread('2.bmp');
imgread = rgb2gray(mat);
mbt=imresize(mba,size(imgread));
mbt = uint8(mbt);
[maa,mab] = size(imgread);
[mba,mbb] = size(mbt);
md = ones(maa,mab);
ma = zeros(2*maa,2*mab);
ma = im2uint8(ma);

% progress the image
for i=1:1:maa

for j=1:1:mab

imgread(i,j)=imgread(i,j)-mod(imgread(i,j),4);
end
end

%========================
%enlarge image

%=======================
for j=1:1:mab
for i=1:1:maa

ma(2*i-1,2*j-1) = imgread(i,j);
ma(2*i,2*j-1) = imgread(i,j);
ma(2*i-1,2*j) = imgread(i,j);

ma(2*i,2*j) = imgread(i,j);
mb(2*i-1,2*j-1) = mbt(i,j);
mb(2*i,2*j-1) = mbt(i,j);
mb(2*i-1,2*j) = mbt(i,j);

mb(2*i,2*j) = mbt(i,j);
end
end

ma = ma+mb*3;
%ma = ma-mb*3;
%=======================
% attack

%=======================

noise = normrnd(0,0.2,2*maa,2*mab); %Gaussian, uniform,

% laplace,salt-pepper
ma = double(ma);
ma = ma+ noise;
ma = uint8(ma);
figure(1);

subplot(2,2,1);imshow(imgread);
subplot(2,2,2);imshow(mbt,[0,1]);
subplot(2,2,3);imshow(ma);
subplot(2,2,4);imshow(noise)%

%subplot(2,2,1);imshow(mb,[0,1]);subplot(2,2,2);imshow(ma);subplot(2,2,3);imshow(mc);

%=======================
% watermark extraction
%=======================
for i=1:1:maa

for j=1:1:mab

a=mod(ma(2*i-1,2*j-1),2)+mod(ma(2*i,2*j-1),2)+mod(ma(2*i-1,2*j),2)+mod(ma(2*i,2*j),2);

a=(-a+mod(ma(2*i-1,2*j-1),4)+mod(ma(2*i,2*j-1),4)+mod(ma(2*i-1,2*j),4)+mod(ma(2*i,2*j),4))/2;

if a<4

md(i,j)=0;
else
md(i,j)=1;
end
end
end

md = uint8(md);
figure(2);imshow(md,[0,1]);
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式