<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta name="generator" content="pdf2htmlEX">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css">
<link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css">
<link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/626c88481fd0a579527a4bfb/raw.css">
<script src="https://static.pudn.com/base/js/compatibility.min.js"></script>
<script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script>
<script>
try{
pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({});
}catch(e){}
</script>
<title></title>
</head>
<body>
<div id="sidebar" style="display: none">
<div id="outline">
</div>
</div>
<div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/626c88481fd0a579527a4bfb/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">批量检测火焰图片</div><div class="t m0 x1 h4 y3 ff2 fs1 fc0 sc1 ls0 ws0">srcDir=uigetdir(<span class="fc1">'D:\<span class="ff1">毕设相关</span>\<span class="ff1">火灾</span>ire\'</span>); <span class="fc2">%<span class="ff1">获得选择的文件夹</span></span></div><div class="t m0 x1 h5 y4 ff2 fs1 fc0 sc1 ls0 ws0">cd(srcDir);</div><div class="t m0 x1 h4 y5 ff2 fs1 fc0 sc1 ls0 ws0">allnames=struct2cell(dir(<span class="fc1">'*.jpg'</span>)); <span class="fc2">%<span class="ff1">只处理<span class="_ _0"> </span></span>8<span class="_ _0"> </span><span class="ff1">位的<span class="_ _0"> </span></span>jpg<span class="_ _0"> </span><span class="ff1">文件</span></span></div><div class="t m0 x1 h4 y6 ff2 fs1 fc0 sc1 ls0 ws0">[k,len]=size(allnames); <span class="fc2">%<span class="ff1">获得<span class="_ _0"> </span></span>jpg<span class="_ _0"> </span><span class="ff1">文件的个数</span></span></div><div class="t m0 x1 h5 y7 ff2 fs1 fc3 sc1 ls0 ws0">for<span class="fc0"> ii=1:len</span></div><div class="t m0 x1 h4 y8 ff2 fs1 fc2 sc1 ls0 ws0">%<span class="ff1">逐次取出文件</span></div><div class="t m0 x1 h5 y9 ff2 fs1 fc0 sc1 ls0 ws0">name=allnames{1,ii};</div><div class="t m0 x1 h4 ya ff2 fs1 fc0 sc1 ls0 ws0">RGB=imread(name); <span class="fc2">%<span class="ff1">读取文件</span></span></div><div class="t m0 x1 h5 yb ff2 fs1 fc0 sc1 ls0 ws0">figure;</div><div class="t m0 x1 h4 yc ff2 fs1 fc0 sc1 ls0 ws0">subplot(231);imshow(RGB);title(<span class="fc1">'<span class="ff1">原图</span>'</span>);</div><div class="t m0 x1 h5 yd ff2 fs1 fc0 sc1 ls0 ws0">r=RGB(:,:,1);</div><div class="t m0 x1 h5 ye ff2 fs1 fc0 sc1 ls0 ws0">g=RGB(:,:,2);</div><div class="t m0 x1 h5 yf ff2 fs1 fc0 sc1 ls0 ws0">b=RGB(:,:,3);</div><div class="t m0 x1 h5 y10 ff2 fs1 fc0 sc1 ls0 ws0">bw=im2bw(RGB);</div><div class="t m0 x1 h5 y11 ff2 fs1 fc0 sc1 ls0 ws0">bw=double(bw);</div><div class="t m0 x1 h5 y12 ff2 fs1 fc0 sc1 ls0 ws0">r=double(r);</div><div class="t m0 x1 h5 y13 ff2 fs1 fc0 sc1 ls0 ws0">g=double(g);</div><div class="t m0 x1 h5 y14 ff2 fs1 fc0 sc1 ls0 ws0">b=double(b);</div><div class="t m0 x1 h5 y15 ff2 fs1 fc0 sc1 ls0 ws0">r1=r.*bw;</div><div class="t m0 x1 h5 y16 ff2 fs1 fc0 sc1 ls0 ws0">g1=g.*bw;</div><div class="t m0 x1 h5 y17 ff2 fs1 fc0 sc1 ls0 ws0">b1=b.*bw;</div><div class="t m0 x1 h4 y18 ff2 fs1 fc0 sc1 ls0 ws0">subplot(2,3,2);imshow(mat2gray(r1));title(<span class="fc1">'<span class="ff1">红色分量</span>'</span>)<span class="fc2">%<span class="ff1">这个图是用<span class="_ _0"> </span></span>r<span class="_ _0"> </span><span class="ff1">分量与<span class="_ _0"> </span></span>bw<span class="_ _0"> </span><span class="ff1">相</span></span></div><div class="t m0 x1 h4 y19 ff1 fs1 fc2 sc1 ls0 ws0">乘,那么我觉得图中有图像部分就应该是火焰的红色信息</div><div class="t m0 x1 h4 y1a ff2 fs1 fc0 sc1 ls0 ws0">subplot(2,3,3);imshow(mat2gray(g1));title(<span class="fc1">'<span class="ff1">绿色分量</span>'</span>)</div><div class="t m0 x1 h4 y1b ff2 fs1 fc0 sc1 ls0 ws0">subplot(2,3,4);imshow(mat2gray(b1));title(<span class="fc1">'<span class="ff1">蓝色分量</span>'</span>)</div><div class="t m0 x1 h5 y1c ff2 fs1 fc0 sc1 ls0 ws0">k=imsubtract(r1,g1);</div><div class="t m0 x1 h5 y1d ff2 fs1 fc0 sc1 ls0 ws0">subplot(235),imshow(k);title(<span class="fc1">'k>0'</span>)</div><div class="t m0 x1 h5 y1e ff2 fs1 fc0 sc1 ls0 ws0">y=k>30</div><div class="t m0 x1 h5 y1f ff2 fs1 fc0 sc1 ls0 ws0">subplot(236);imshow(y);title(<span class="fc1">'k>30'</span>)</div><div class="t m0 x1 h5 y20 ff2 fs1 fc3 sc1 ls0 ws0">end</div></div></div><div class="pi" data-data='{"ctm":[1.568627,0.000000,0.000000,1.568627,0.000000,0.000000]}'></div></div>
</body>
</html>