【元胞自动机】基于元胞自动机实现图像处理matlab源码

元胞自动机(Cellular Automaton),复数为Cellular Automata,简称CA,也有人译为细胞自动机、点格自动机、分子自动机或单元自动机)。是一时间和空间都离散的动力系统。散布在规则格网 (Lattice Grid)中的每一元胞(Cell)取有限的离散状态,遵循同样的作用规则,依据确定的局部规则作同步更新。大量元胞通过简单的相互作用而构成精态系统的演化。由冯诺依曼在20世纪50年代发明。

其特点是时间、空间、状态都离散,每个变量只取有限多个状态,且其状态改变的规则在时间和空间上都是局部的。

将所有元胞自动机的动力学行为归纳为四大类(Wolfram. S.,1986):

⑴平稳型:自任何初始状态开始,经过一定时间运行后,元胞空间趋于一个空间平稳的构形,这里空间平稳即指每一个元胞处于固定状态。不随时间变化而变化。

⑵周期型:经过一定时间运行后,元胞空间趋于一系列简单的固定结构(Stable Patterns)或周期结构(Perlodical Patterns)。由于这些结构可看作是一种 滤波器(Filter),故可应用到 图像处理的研究中。

⑶混沌型:自任何初始状态开始,经过一定时间运行后,元胞自动机表现出混沌的非周期行为,所生成的结构的统计特征不再变止,通常表现为分形 分维特征。

⑷复杂型:出现复杂的局部结构,或者说是局部的混沌,其中有些会不断地传播。

上述分类,又可以分别描述为( 谭跃进,1996; 谢惠民,1994;李才伟、1997);

⑴均匀状态,即点态 吸引子,或称不动点;

⑵简单的周期结构,即周期性吸引子,或称周期轨;

⑶混沌的非周期性模式,即混沌吸引子;

⑷这第四类行为可以与 生命系统等复杂系统中的 自组织现象相比拟,但在 连续系统中没有相对应的模式。但从研究元胞自动机的角度讲,最具研究价值的具有第四类行为的元胞自动机,因为这类元胞自动机被认为具有"突现计算"(Emergent Computation)功能,研究表明,可以用作广义计算机(Universal Computer)以 仿真任意复杂的计算过程。另外,此类元胞自动机在发展过程中还表现出很强的不可逆(lrreversibility)特征,而且,这种元胞自动机在若干有限循环后,有可能会 "死"掉,即所有元胞的状态变为零。

``` function varargout = ES(varargin)

% ES MATLAB code for ES.fig

% ES, by itself, creates a new ES or raises the existing

% singleton*.

%

% H = ES returns the handle to a new ES or the handle to

% the existing singleton*.

%

% ES('CALLBACK',hObject,eventData,handles,...) calls the local

% function named CALLBACK in ES.M with the given input arguments.

%

% ES('Property','Value',...) creates a new ES or raises the

% existing singleton*. Starting from the left, property value pairs are

% applied to the GUI before ES_OpeningFcn gets called. An

% unrecognized property name or invalid value makes property application

% stop. All inputs are passed to ES_OpeningFcn via varargin.

%

% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one

% instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help ES

% Last Modified by GUIDE v2.5 24-Nov-2014 16:51:08

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

guiState = struct('guiName', mfilename, ...

'guiSingleton', guiSingleton, ...

'guiOpeningFcn', @ESOpeningFcn, ...

'guiOutputFcn', @ESOutputFcn, ...

'gui_LayoutFcn', [] , ...

'gui_Callback', []);

if nargin && ischar(varargin{1})

guiState.guiCallback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = guimainfcn(guiState, varargin{:});

else

guimainfcn(guiState, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before ES is made visible.

function ES_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% varargin command line arguments to ES (see VARARGIN)

% Choose default command line output for ES

handles.output = hObject;

handles.Img = 0;

handles.ParentImg = 0;

handles.OffspringImg = 0;

handles.Parent = cell(1, 8);

handles.Parent{1} = zeros(1, 3); % Birth

handles.Parent{2} = zeros(1, 3); % Level

handles.Parent{3} = zeros(1, 3); % number of Pattern Pos

handles.Parent{4} = cell(1, 3); % PosH

handles.Parent{5} = cell(1, 3); % PosW

handles.Parent{6} = zeros(1, 3); % Cell Generation

handles.Parent{7} = cell(1, 3); % Pattern

handles.Offspring = cell(1, 8);

handles.Offspring{1} = zeros(1, 3); % Birth

handles.Offspring{2} = zeros(1, 3); % Level

handles.Offspring{3} = zeros(1, 3); % number of Pattern Pos

handles.Offspring{4} = cell(1, 3); % PosH

handles.Offspring{5} = cell(1, 3); % PosW

handles.Offspring{6} = zeros(1, 3); % Cell Generation

handles.Offspring{7} = cell(1, 3); % Pattern

handles.Boundary = cell(1, 7); % Birth, Level, # of CellBlocks, MinCAG, MaxCAG, Image Size

handles.GenerationCount = 0;

if exist('iES', 'dir') ~= 7

mkdir('iES');

end

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes ES wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = ES_OutputFcn(hObject, eventdata, handles)

% varargout cell array for returning output args (see VARARGOUT);

% hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure

varargout{1} = handles.output;

function BirthVal_Callback(hObject, eventdata, handles)

% hObject handle to BirthVal (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of BirthVal as text

% str2double(get(hObject,'String')) returns contents of BirthVal as a double

% --- Executes during object creation, after setting all properties.

function BirthVal_CreateFcn(hObject, eventdata, handles)

% hObject handle to BirthVal (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

function LevelVal_Callback(hObject, eventdata, handles)

% hObject handle to LevelVal (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of LevelVal as text

% str2double(get(hObject,'String')) returns contents of LevelVal as a double

% --- Executes during object creation, after setting all properties.

function LevelVal_CreateFcn(hObject, eventdata, handles)

% hObject handle to LevelVal (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

function CellBlocksVal_Callback(hObject, eventdata, handles)

% hObject handle to CellBlocksVal (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of CellBlocksVal as text

% str2double(get(hObject,'String')) returns contents of CellBlocksVal as a double

% --- Executes during object creation, after setting all properties.

function CellBlocksVal_CreateFcn(hObject, eventdata, handles)

% hObject handle to CellBlocksVal (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

function MinCAGVal_Callback(hObject, eventdata, handles)

% hObject handle to MinCAGVal (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of MinCAGVal as text

% str2double(get(hObject,'String')) returns contents of MinCAGVal as a double

% --- Executes during object creation, after setting all properties.

function MinCAGVal_CreateFcn(hObject, eventdata, handles)

% hObject handle to MinCAGVal (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

function MaxCAGVal_Callback(hObject, eventdata, handles)

% hObject handle to MaxCAGVal (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of MaxCAGVal as text

% str2double(get(hObject,'String')) returns contents of MaxCAGVal as a double

% --- Executes during object creation, after setting all properties.

function MaxCAGVal_CreateFcn(hObject, eventdata, handles)

% hObject handle to MaxCAGVal (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

% --- Executes on button press in ImgRead.

function ImgRead_Callback(hObject, eventdata, handles)

% hObject handle to ImgRead (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% [filename, user_canceled] = imgetfile;

% if user_canceled

% return;

% end

filename = 'lenna.png';

Img = imread(filename);

handles.Img = Img;

axes(handles.Original);

image(double(handles.Img)/255);

guidata(hObject, handles);

% --- Executes on button press in Sellambda.

function Sellambda_Callback(hObject, eventdata, handles)

% hObject handle to Sellambda (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

imwrite(handles.ParentImg, ['iEA/G', num2str(handles.GenerationCount), '.jpg']);

[handles.Offspring, cc] = Mutation(handles.Parent, handles.Boundary);

guidata(hObject, handles);

offspring = handles.ParentImg;

[offspring(:, :, cc), ta, tb, tc, td, te] = GUILogicRule(handles.Img, cc, handles.Offspring{1}(cc), handles.Offspring{2}(cc), handles.Offspring{3}(cc), handles.Offspring{6}(cc), 1, handles.Offspring{4}{cc}, handles.Offspring{5}{cc}, handles.Offspring{7}{cc});

axes(handles.mu);

image(offspring);

handles.GenerationCount = handles.GenerationCount +1;

handles.OffspringImg = offspring;

guidata(hObject, handles);

set(handles.Generation, 'string', strcat('Generation: ', num2str(handles.GenerationCount)));

% --- Executes on button press in Selmu.

function Selmu_Callback(hObject, eventdata, handles)

% hObject handle to Selmu (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

imwrite(handles.OffspringImg, ['iEA/G', num2str(handles.GenerationCount), '.jpg']);

[handles.Parent, cc] = Mutation(handles.Offspring, handles.Boundary);

guidata(hObject, handles);

Parent = handles.OffspringImg;

[Parent(:, :, cc), ta, tb, tc, td, te] = GUILogicRule(handles.Img, cc, handles.Parent{1}(cc), handles.Parent{2}(cc), handles.Parent{3}(cc), handles.Parent{6}(cc), 1, handles.Parent{4}{cc}, handles.Parent{5}{cc}, handles.Parent{7}{cc});

axes(handles.lambda);

image(Parent);

handles.GenerationCount = handles.GenerationCount +1;

handles.ParentImg = Parent;

guidata(hObject, handles);

set(handles.Generation, 'string', strcat('Generation: ', num2str(handles.GenerationCount)));

% --- Executes on button press in Start.

function Start_Callback(hObject, eventdata, handles)

% hObject handle to Start (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

handles.GenerationCount = 1;

Parent = zeros(size(handles.Img));

Sz = size(handles.Img);

Birth = str2double(get(handles.BirthVal, 'string'));

Level = str2double(get(handles.LevelVal, 'string'));

NumCellBlocks = str2double(get(handles.CellBlocksVal, 'string'));

MinCAG = str2double(get(handles.MinCAGVal, 'string'));

MaxCAG = str2double(get(handles.MaxCAGVal, 'string'));

for cc=1:3

CellGen = randi([MinCAG, MaxCAG]);

PosH = randi([1, Sz(1)], 1, NumCellBlocks);

PosW = randi([1, Sz(2)], 1, NumCellBlocks);

[Parent(:, :, cc), handles.Parent{6}(cc), handles.Parent{1}(cc), handles.Parent{2}(cc), handles.Parent{3}(cc), handles.Parent{7}{cc}] = GUILogicRule(handles.Img, cc, Birth, Level, NumCellBlocks, CellGen, 0, PosH, PosW, 0);

handles.Parent{4}{cc} = PosH;

handles.Parent{5}{cc} = PosW;

guidata(hObject, handles);

end

handles.Boundary{1} = Birth;

handles.Boundary{2} = Level;

handles.Boundary{3} = NumCellBlocks;

handles.Boundary{4} = MinCAG;

handles.Boundary{5} = MaxCAG;

handles.Boundary{6} = Sz(1);

handles.Boundary{7} = Sz(2);

guidata(hObject, handles);

handles.Offspring = Mutation(handles.Parent, handles.Boundary);

guidata(hObject, handles);

offspring = zeros(Sz);

for cc=1:3

[offspring(:, :, cc), ta, tb, tc, td, te] = GUILogicRule(handles.Img, cc, handles.Offspring{1}(cc), handles.Offspring{2}(cc), handles.Offspring{3}(cc), handles.Offspring{6}(cc), 1, handles.Offspring{4}{cc}, handles.Offspring{5}{cc}, handles.Offspring{7}{cc});

end

handles.ParentImg = Parent;

handles.OffspringImg = offspring;

guidata(hObject, handles);

axes(handles.lambda);

image(Parent);

axes(handles.mu);

image(offspring);

set(handles.Generation, 'string', strcat('Generation: ', num2str(handles.GenerationCount))); ```

  • 🎈 部分理论引用网络文献,若有侵权联系博主删除
    👇 关注我领取海量matlab电子书和数学建模资料

    🎁 私信完整代码和数据获取及论文数模仿真定制

    🌈 各类智能优化算法改进及应用
    生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化、背包问题、 风电场布局、时隙分配优化、 最佳分布式发电单元分配、多阶段管道维修、 工厂-中心-需求点三级选址问题、 应急生活物质配送中心选址、 基站选址、 道路灯柱布置、 枢纽节点部署、 输电线路台风监测装置、 集装箱调度、 机组优化、 投资优化组合、云服务器组合优化、 天线线性阵列分布优化、CVRP问题、VRPPD问题、多中心VRP问题、多层网络的VRP问题、多中心多车型的VRP问题、 动态VRP问题、双层车辆路径规划(2E-VRP)、充电车辆路径规划(EVRP)、油电混合车辆路径规划、混合流水车间问题、 订单拆分调度问题、 公交车的调度排班优化问题、航班摆渡车辆调度问题、选址路径规划问题、港口调度、港口岸桥调度、停机位分配、机场航班调度、泄漏源定位
    🌈 机器学习和深度学习时序、回归、分类、聚类和降维

    2.1 bp时序、回归预测和分类

    2.2 ENS声神经网络时序、回归预测和分类

    2.3 SVM/CNN-SVM/LSSVM/RVM支持向量机系列时序、回归预测和分类

    2.4 CNN|TCN|GCN卷积神经网络系列时序、回归预测和分类

    2.5 ELM/KELM/RELM/DELM极限学习机系列时序、回归预测和分类
    2.6 GRU/Bi-GRU/CNN-GRU/CNN-BiGRU门控神经网络时序、回归预测和分类

    2.7 ELMAN递归神经网络时序、回归\预测和分类

    2.8 LSTM/BiLSTM/CNN-LSTM/CNN-BiLSTM/长短记忆神经网络系列时序、回归预测和分类

    2.9 RBF径向基神经网络时序、回归预测和分类

    2.10 DBN深度置信网络时序、回归预测和分类
    2.11 FNN模糊神经网络时序、回归预测
    2.12 RF随机森林时序、回归预测和分类
    2.13 BLS宽度学习时序、回归预测和分类
    2.14 PNN脉冲神经网络分类
    2.15 模糊小波神经网络预测和分类
    2.16 时序、回归预测和分类
    2.17 时序、回归预测预测和分类
    2.18 XGBOOST集成学习时序、回归预测预测和分类
    2.19 Transform各类组合时序、回归预测预测和分类
    方向涵盖风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、用电量预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断
    🌈图像处理方面
    图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知
    🌈 路径规划方面
    旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、 充电车辆路径规划(EVRP)、 双层车辆路径规划(2E-VRP)、 油电混合车辆路径规划、 船舶航迹规划、 全路径规划规划、 仓储巡逻
    🌈 无人机应用方面
    无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配、无人机安全通信轨迹在线优化、车辆协同无人机路径规划
    🌈 通信方面
    传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化、水声通信、通信上传下载分配
    🌈 信号处理方面
    信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化、心电信号、DOA估计、编码译码、变分模态分解、管道泄漏、滤波器、数字信号处理+传输+分析+去噪、数字信号调制、误码率、信号估计、DTMF、信号检测
    🌈电力系统方面
    微电网优化、无功优化、配电网重构、储能配置、有序充电、MPPT优化、家庭用电
    🌈 元胞自动机方面
    交通流 人群疏散 病毒扩散 晶体生长 金属腐蚀
    🌈 雷达方面
    卡尔曼滤波跟踪、航迹关联、航迹融合、SOC估计、阵列优化、NLOS识别
    🌈 车间调度
    零等待流水车间调度问题NWFSP置换流水车间调度问题PFSP混合流水车间调度问题HFSP 、零空闲流水车间调度问题NIFSP、分布式置换流水车间调度问题 DPFSP、阻塞流水车间调度问题BFSP
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Matlab科研辅导帮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值