图片隐写技术

        图片隐写大概就是将两个图片经过处理将其信息合成,处理完成后看起来还是其中一张图片,具体的问gpt;

进入正题;

怎么将下面的     沫沫    隐藏在   真冬   里呢?

 

clc;
clear;
close all;

image1 = imread("2024511.jpg");
image2 = imread("2024512.jpg");

%figure;imshow(image1);
%figure;imshow(image2);

image3 = rgb2gray(image1);
image4 = rgb2gray(image2);

%figure;imshow(image3);
%figure;imshow(image4);

image5 = idivide(image3, 10) * 10;
image6 = image4 * (9 / 255);
%image7 = image6 * (255 / 9);


imtool(image5);
imtool(image6);
%imtool(image7);

imageall = image5 + image6;
%imshow(imageall);
imwrite(imageall,"output2024511.png");
imtool(imageall);

得到输出图像;

 成功进行图片隐写;

别人得到这副图像,就要分离图像才能看到 沫沫

clc;
clear;
close all;

img0 = imread("output2024511.png");
imtool("output2024511.png")

img1 = idivide(img0, 10) * 10;
%imtool(img1);

img2 = img0 - img1;
imtool(img2);

img3 = img2 * (255 / 9);
imtool(img3);

 得到最终图像

 但是如果想得到最终的彩色图像怎么办?

那么就不能转为灰度图,而是将r,g,b拆开分开进行图片隐写,即得到三幅灰度图像;分别分裂图像后将对应的r,g,b灰度图融合,就得到彩色图片了;

function [img0]= encode(img1, img2)
    img3 = idivide(img1, 10) * 10;
    img4 = img2 * (9 / 255);
    img0 = img3 + img4;
end
function [img1, img3]= decode(img0)
    img1 = idivide(img0, 10) * 10;
    img2 = img0 - img1;
    img3 = img2 * (255 / 9);
end
clc;
clear;
close all;

img1 = imread("2024511.jpg");
img2 = imread("2024512.jpg");

img1_r = img1(:,:,1);
img1_g = img1(:,:,2);
img1_b = img1(:,:,3);

img2_r = img2(:,:,1);
img2_g = img2(:,:,2);
img2_b = img2(:,:,3);

img3_r = encode(img1_r, img2_r);
img3_g = encode(img1_g, img2_g);
img3_b = encode(img1_b, img2_b);

%figure;imshow(img3_r);
%figure;imshow(img3_g);
%figure;imshow(img3_b);

[img4_r, img5_r] = decode(img3_r);
[img4_g, img5_g] = decode(img3_g);
[img4_b, img5_b] = decode(img3_b);

img6 = cat(3, img4_r, img4_g, img4_b);
img7 = cat(3, img5_r, img5_g, img5_b);

figure;imshow(img6);
figure;imshow(img7);
imwrite(img6,'output2024512.png')
imwrite(img7,'output2024513.png')

得到的三幅隐写图像为;

最终输出的彩色图像;

在做一个对比吧:

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值