信息隐藏LSB
2016-06-20 21:39
162 查看
学习别人的代码实现对音频(wav)和图像的傅里叶变换分析:clearlen = 400000;[fn,pn] = uigetfile('*.wav' , '请选择音频文件');[x,fs] = wavread(strcat(pn,fn),len);xf = fft(x);f1 = [0:len-1]*fs/len;xff = fftshift(xf);h1 = floor(len/2) - 5;f2 = [-h1,h1]*fs/len;xsync = ifft(xf);xff = abs(xff);figure;subplot(2 , 2 , 1);plot(x);title('original audio');subplot(2 , 2 , 2);plot(xsync);title('synthesize audio');subplot(2 , 2 , 3);plot(f1,abs(xf));title('fft coef. of audio');subplot(2 , 2 , 4);plot(f2(1:len-2) , abs(xff-3));title('fftshift coef. of audio');
<pre name="code" class="plain">clearlen = 400000;[fn,pn] = uigetfile('*.bmp' , '请选择图像文件');[x,map] = imread(strcat(pn,fn));I = rgb2gray(x);xf = fft2(I);xff = fftshift(xf);xsync = ifft2(xf);figure;subplot(2 , 2 , 1);imshow(x);title('original image');subplot(2 , 2 , 2);imshow(uint8(abs(xsync)));title('synthesize image');subplot(2 , 2 , 3);mesh(abs(xf));title('fft coef. of image');subplot(2 , 2 , 4);mesh(abs(xff));title('fftshift coef. of image');LSB顺序加密和解密:加密:clear[fn,pn] = uigetfile('*.bmp' , '请选择图像文件');path = strcat(pn , fn);Picture = imread(path,'bmp');[fn2,pn2] = uigetfile('*.txt' , '请选择加密文本文件');path2 = strcat(pn2 , fn2);Double_Picture = Picture;Double_Picture = double(Double_Picture);%将图像转换成二进制path2_id = fopen(path2 , 'r'); %读取秘密信息文件[msg , len] = fread(path2_id , 'ubit1');[m , n] = size(Double_Picture);p = 1; %p为秘密信息的计数器for f2 = 1:nfor f1 = 1:mDouble_Picture(f1 , f2) = Double_Picture(f1,f2) - mod(Double_Picture(f1 , f2) , 2) + msg(p , 1);if(p == len)break;end;p = p + 1;end;if(p == len)break;end;end;Double_Picture = uint8(Double_Picture);imwrite(Double_Picture , strcat(pn , '_隐藏图像.bmp'));subplot(1 , 2 , 1) ; imshow(Picture);title('原始图像');subplot(1 , 2 , 2) ; imshow(Double_Picture);title('加密图像');解密:clear[fn,pn] = uigetfile('*.bmp' , '请选择加密图像文件');path = strcat(pn , fn);Picture = imread(path,'bmp');Picture = double(Picture);[m,n] = size(Picture);frr = fopen('d:\\解密文档.txt' , 'a');len = 57984; % 设定隐秘信息长度p = 1;for f2 = 1:nfor f1 = 1:mif bitand(Picture(f1,f2) , 1) == 1 % 顺序提取fwrite(frr , 1 , 'ubit1');% result(p , 1) = 1;elsefwrite(frr , 0 , 'ubit1');% result(p , 1) = 0;end;if p==lenbreak;end;p = p + 1;end;if p== lenbreak;end;end;fclose(frr);
相关文章推荐
- Android中的Activity4中启动模式使用场景
- 软件工程个人总结
- JDK环境变量的配置
- Ubuntu安装JDK
- 流密码和RC4
- 软件工程概论个人总结
- caffe基础(1):数据层及参数
- 粘连 Footer 的 5 种方法 | CSS-Tricks
- Servlet过滤器——日志记录过滤器
- sublime编辑器【快捷键】基本用法,sublime小技巧
- mac上搭建python虚拟开发环境
- Struts2输入校验field-validator type 可取得值
- git命令小结
- 差分约束系统
- Vijos-1243 生产产品 (DP单调队列优化)
- 关于PHP的自动加载
- 浅谈LoRaWAN
- [DP] BZOJ 4244 邮戳拉力赛
- python dictionary
- Woobuntu的安装