1、混沌系统
(1)绘制序列
语法:y = linspace(x1,x2,n)
序列值分布:(x2-x1)/(n-1)
%% 绘制序列 x = linspace(0,0,100); x(1) = 0.98; for i = 2:100; x(i) = 1-2*x(i-1)*x(i-1); end plot(x)
(2)初始值敏感性
%% 初始值敏感性 long = 100; a = linspace(0,0,long); a(1) = 0.98; for i = 2:long; a(i) = 1-2*a(i-1)*a(i-1); end b = linspace(0,0,long); b(1) = 0.980001; for i = 2:long; b(i) = 1-2*b(i-1)*b(i-1); end plot(a); hold on plot(b)
(3)二值化处理
%% 二值化处理 a = linspace(0,0,80); a(1) = 0.98; for i = 2:80; a(i) = 1-2*a(i-1)*a(i-1); end % plot(a,\'o\'); b = a; for i = 1:80 if a(i)>0 b(i) = 1; else b(i)=0; end end subplot(1,2,1),plot(a,\'o\'); subplot(1,2,2),plot(b,\'ob\');
(4)生成二值混沌系统
%% 生成二值混沌图像 a = zeros(512,512); a(1) = 0.98; for i =2:512*512 a(i) = 1-2*a(i-1)*a(i-1); end for i = 1:512*512 if a(i)>0 a(i)=1; else a(i)=0; end end imshow(a);
(5)生成灰度混沌图像
%% 生成灰度混沌图像 clc; clear all; a = zeros(512,512); a(1) = 0.98; for i =2:512*512 a(i) = 1-2*a(i-1)*a(i-1); end % 对a的值进行转换 b = zeros(512,512); b = mod(round(a*98989898989898),256); imshow(b,[]);
(6)生成彩色混沌图像
%% 生产彩色混沌图像 r = zeros(512,512); r(1) = 0.98; for i = 2:512*512 r(i) = 1-2*r(i-1)*r(i-1); end r = mod(round(r*10000000),256); g = zeros(512,512); g(1) = 0.59; for i = 2:512*512 g(i) = 1-2*g(i-1)*g(i-1); end g = mod(round(g*10000000),256); b = zeros(512,512); b(1) = 0.236; for i = 2:512*512 b(i) = 1-2*b(i-1)*b(i-1); end b = mod(round(b*10000000),256); c = zeros(512,512,3); c = cat(3,r,g,b); imshow(uint8(c));
2、函数
(1)函数构建
(2)生成二值混沌图像函数
① 函数生成:
function bitI = creatBI(oValue) % 生成二值混沌图像 bitI = zeros(512,512); % 生成混沌数组 l = zeros(512,512); l(1) = oValue; for i = 2:512*512 l(i) = 1-2*l(i-1)*l(i-1); end % 二值化 for i = 1:512*512 if l(i)>0 bitI(i)=1; else bitI(i)=0; end end
② 函数调用:
%% 二值混沌图像函数调用 t = creatBI(0.98); imshow(t);
(3)生成灰度混沌图像函数
① 生成函数:
function grayImage = grayImage(oValue) % 生成灰度混沌图像 l = zeros(512,512); grayIamge = zeros(512,512); l(1) = oValue; for i = 2:512*512 l(i) = 1-2*l(i-1)*l(i-1); end grayImage=mod(round(l*100000000),256); grayImage=uint8(grayImage);
② 函数调用:
%% 灰度混沌图像函数调用 x = grayImage(0.98); imshow(x);
(4)生成彩色混沌图像函数
① 生成函数:
function x = RgbImage(oValue1,oValue2,oValue3) % 生成彩色混沌图像 % 方法一:重写 % r = zeros(512,512); % g = zeros(512,512); % b = zeros(512,512); % % % red通道 % r(1) = oValue1; % for i =2:512*512 % r(i) = 1-2*r(i-1)*r(i-1); % end % r = mod(round(r*100000000),256); % % green通道 % g(1) = oValue2; % for i =2:512*512 % g(i) = 1-2*g(i-1)*g(i-1); % end % g = mod(round(g*100000000),256); % % blue通道 % b(1) = oValue3; % for i =2:512*512 % b(i) = 1-2*b(i-1)*b(i-1); % end % b = mod(round(b*100000000),256); % % % 合成 % x = cat(3,r,g,b); % x = uint8(x); % 方法2:调用灰度混沌生成函数 r = grayImage(oValue1); g = grayImage(oValue2); b = grayImage(oValue3); x = cat(3,r,g,b); x = uint8(x);
② 函数调用:
%% 彩色混沌图像函数调用 x = RgbImage(0.98,0.56,0.23); imshow(x);
请发表评论