资源简介
利用MATLAB编写的烟雾检测程序,烟雾追踪程序,毕业设计验证过,珍藏多年了

代码片段和文件信息
tic;
clear all;
close all;
clc;
alpha = 0.5;
v=3;
% vid = videoinput(‘winvideo‘ 1);%创建ID为1的摄像头的视频对象。
% set(vid‘ReturnedColorSpace‘‘rgb‘);
% vidRes=get(vid‘VideoResolution‘);
% width=vidRes(1);
% height=vidRes(2);
% nBands=get(vid‘NumberOfBands‘);
% figure(‘Name‘ ‘Matlab调用摄像头 By tennfy‘ ‘Numbertitle‘ ‘Off‘ ‘ToolBar‘ ‘None‘ ‘MenuBar‘ ‘None‘);
% hImage=image(zeros(vidRes(2)vidRes(1)nBands));
% preview(vidhImage); %打开视频预览窗口
% filename = ‘screen_video‘;%保存视频的名字
% nframe = 150; %视频的帧数
% nrate = 30; %每秒的帧数
% preview(vid);
% set(1‘visible‘‘off‘);
%
% writerObj = VideoWriter( [filename ‘.avi‘] );
% writerObj.frameRate = nrate;
% open(writerObj);
%
% figure;
% for ii = 1: nframe
% frame = getsnapshot(vid);
% imshow(frame);
% f.cdata = frame;
% f.colormap = colormap([]) ;
% writeVideo(writerObjf);
% end
% close(writerObj);
% closepreview
A = aviinfo(‘screen_video.avi‘);
mov = mmreader(‘screen_video.avi‘);
LEN = A.Numframes;%得到视频的帧数
for i = 1:v: LEN
b = read(mov i);
imwrite(b strcat(‘smoke‘ int2str(i/v) ‘.jpg‘) ‘jpg‘);
end
pic = imread(strcat(‘smoke‘ int2str(i/v) ‘.jpg‘));%读入一张图片
[rowcolkkkk] = size(pic);
OrDiffPic = 255*zeros(rowcol);
%Ncut =20;
Ncut =20;
Nrow = floor(row/Ncut);
Ncol = floor(col/Ncut);
%定义新的块状像素图像
CubePic = 255*zeros(NrowNcol);
DiffPic = 255*zeros(NrowNcol);
BackPic = 255*zeros(NrowNcol);
thres = 10;
%TestPic = 255*ones(rowcol);
flag = 0;
counter = 0;
for x = 1 : (LEN/v)-1
pic = imread(strcat(‘smoke‘ int2str(x) ‘.jpg‘));%读入一张图片
pic1 = rgb2gray(pic);
% imshow(pic1);
%thres = mean(pic11);
%块状像素点平均化
for i=1:Nrow
for j = 1:Ncol
temp = pic1((i-1)*Ncut+1:i*Ncut(j-1)*Ncut+1:j*Ncut);
CubePic(ij) = uint8(mean(temp(:)));
end
end
%imshow(uint8(CubePic));
%背景减除
if x==1
BackPic = CubePic;
else
DiffPic = uint8(CubePic) - uint8(BackPic); %计算背景图片
BackPic = uint8(uint8(alpha*CubePic) + uint8((1-alpha)*BackPic));
end
%imshow(uint8(DiffPic));
for i=1:Nrow
for j = 1:Ncol
if DiffPic(ij)>thres
DiffPic(ij) = 255;
else
DiffPic(ij) = 0;
end
end
end
%图像还原成原始尺寸
OrDiffPic = imresize(DiffPicNcut);
imLabel=bwlabel(OrDiffPic8);
im2double(OrDiffPic);
stat = regionprops(imLabel‘Area‘); %求各连通域的大小
maxarea = [stat.Area];
minlen = min(3length(maxarea));
stats = regionprops(imLabel‘Area‘‘Centroid‘);
rea = [stats.Area];
Center = zeros(32);
for i = 1:minlen
ConIndex = find(rea==maxarea(i));
Center(i:) = stats(ConIndex).Centroid;
end
if x>2
for i=1:3
Y2 = LASTCenter(i2);
for j=1:3
Y1 = Center(j2);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4402 2018-05-22 19:17 FIG\perfect.m
目录 0 2016-06-13 16:01 FIG
----------- --------- ---------- ----- ----
4402 2
- 上一篇:初始对准程序
- 下一篇:无限大障板上的活塞辐射
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论