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]);
求大神给讲讲这段程序啥意思 高分 展开
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]);
求大神给讲讲这段程序啥意思 高分 展开
2个回答
展开全部
% 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]);
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 广告
2024-07-20 广告
博思AIPPT是基于ai制作PPT的智能在线工具,它提供了4种AI制作PPT的方式,包括AI生成大纲、AI直接生成PPT、文本生成PPT、AI提炼文档生成PPT,一站式集成多种AI生成PPT的方式,可满足办公用户的不同需求和使用场景。ai生...
点击进入详情页
本回答由博思aippt提供
展开全部
% 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]);
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]);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |