matlab灰度图直方图均衡化代码.zip

  • ll1123
    了解作者
  • matlab
    开发工具
  • 12KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 10 积分
    下载积分
  • 2
    下载次数
  • 2020-06-01 18:05
    上传日期
灰度直方图,利用matlab实现图像的直方图均衡化
matlab灰度图直方图均衡化代码.zip
  • matlab灰度图直方图均衡化代码.docx
    14.9KB
内容介绍
<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/626775914f8811599eeb8e5e/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/626775914f8811599eeb8e5e/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">matlab<span class="_ _0"> </span><span class="ff2">&#28784;&#24230;&#22270;&#30452;&#26041;&#22270;&#22343;&#34913;&#21270;&#20195;&#30721;</span></div><div class="t m0 x1 h4 y3 ff1 fs0 fc0 sc0 ls0 ws0">clear all</div><div class="t m0 x1 h3 y4 ff1 fs0 fc0 sc0 ls0 ws0">%<span class="ff2">&#19968;&#65292;&#22270;&#20687;&#30340;&#39044;&#22788;&#29702;&#65292;&#35835;&#20837;&#24425;&#33394;&#22270;&#20687;&#23558;&#20854;&#28784;&#24230;&#21270;</span></div><div class="t m0 x1 h3 y5 ff1 fs0 fc0 sc0 ls0 ws0">PS=imread('1.jpg'); %<span class="_ _1"></span><span class="ff2">&#35835;&#20837;<span class="_ _0"> </span></span>JPG<span class="_ _0"> </span><span class="ff2">&#24425;&#33394;&#22270;&#20687;&#25991;&#20214;</span></div><div class="t m0 x1 h3 y6 ff1 fs0 fc0 sc0 ls0 ws0">imshow(PS) <span class="_ _1"></span> <span class="_ _2"></span> %<span class="_ _1"></span><span class="ff2">&#26174;&#31034;&#20986;&#26469;</span></div><div class="t m0 x1 h3 y7 ff1 fs0 fc0 sc0 ls0 ws0">title('<span class="ff2">&#36755;&#20837;&#30340;&#24425;&#33394;<span class="_ _0"> </span></span>JPG<span class="_ _0"> </span><span class="ff2">&#22270;&#20687;</span>')</div><div class="t m0 x1 h3 y8 ff1 fs0 fc0 sc0 ls0 ws0">imwrite(rgb2gray(PS),'PicSampleGray.bmp'); %<span class="_ _1"></span><span class="ff2">&#23558;&#24425;&#33394;&#22270;&#29255;&#28784;&#24230;&#21270;&#24182;&#20445;&#23384;</span></div><div class="t m0 x1 h3 y9 ff1 fs0 fc0 sc0 ls0 ws0">PS=rgb2gray(PS); <span class="_ _1"></span> <span class="_ _2"></span> %<span class="ff2">&#28784;&#24230;&#21270;&#21518;&#30340;&#25968;&#25454;&#23384;&#20837;&#25968;&#32452;</span></div><div class="t m0 x1 h3 ya ff1 fs0 fc0 sc0 ls0 ws0">%<span class="ff2">&#20108;&#65292;&#32472;&#21046;&#30452;&#26041;&#22270;</span></div><div class="t m0 x1 h3 yb ff1 fs0 fc0 sc0 ls0 ws0">[m,n]=size(PS); <span class="_ _1"></span> <span class="_ _2"></span> %<span class="_ _1"></span><span class="ff2">&#27979;&#37327;&#22270;&#20687;&#23610;&#23544;&#21442;&#25968;</span></div><div class="t m0 x1 h3 yc ff1 fs0 fc0 sc0 ls0 ws0">GP=zeros(1,256); <span class="_ _1"></span> %<span class="ff2">&#39044;&#21019;&#24314;&#23384;&#25918;&#28784;&#24230;&#20986;&#29616;&#27010;&#29575;&#30340;&#21521;&#37327;</span></div><div class="t m0 x1 h4 yd ff1 fs0 fc0 sc0 ls0 ws0">for k=0:255</div><div class="t m0 x1 h3 ye ff1 fs0 fc0 sc0 ls0 ws0"> <span class="_ _1"></span> <span class="_ _1"></span> <span class="_ _1"></span>GP(k+1)=length(-nd(PS==k))/(m*n); <span class="_ _1"></span> <span class="_ _1"></span> %<span class="_ _3"></span><span class="ff2">&#35745;<span class="_ _1"></span>&#31639;&#27599;<span class="_ _1"></span>&#32423;&#28784;<span class="_ _1"></span>&#24230;&#20986;<span class="_ _1"></span>&#29616;&#30340;<span class="_ _1"></span>&#27010;&#29575;<span class="_ _1"></span>&#65292;&#23558;<span class="_ _1"></span>&#20854;&#23384;<span class="_ _1"></span>&#20837;</span></div><div class="t m0 x1 h3 yf ff1 fs0 fc0 sc0 ls0 ws0">GP<span class="_ _0"> </span><span class="ff2">&#20013;&#30456;&#24212;&#20301;&#32622;</span></div><div class="t m0 x1 h4 y10 ff1 fs0 fc0 sc0 ls0 ws0">end</div><div class="t m0 x1 h3 y11 ff1 fs0 fc0 sc0 ls0 ws0">-gure,bar(0:255,GP,'g') %<span class="_ _1"></span><span class="ff2">&#32472;&#21046;&#30452;&#26041;&#22270;</span></div><div class="t m0 x1 h3 y12 ff1 fs0 fc0 sc0 ls0 ws0">title('<span class="ff2">&#21407;&#22270;&#20687;&#30452;&#26041;&#22270;</span>')</div><div class="t m0 x1 h3 y13 ff1 fs0 fc0 sc0 ls0 ws0">xlabel('<span class="ff2">&#28784;&#24230;&#20540;</span>')</div><div class="t m0 x1 h3 y14 ff1 fs0 fc0 sc0 ls0 ws0">ylabel('<span class="ff2">&#20986;&#29616;&#27010;&#29575;</span>')</div><div class="t m0 x1 h3 y15 ff1 fs0 fc0 sc0 ls0 ws0">%<span class="ff2">&#19977;&#65292;&#30452;&#26041;&#22270;&#22343;&#34913;&#21270;</span></div><div class="t m0 x1 h4 y16 ff1 fs0 fc0 sc0 ls0 ws0">S1=zeros(1,256);</div><div class="t m0 x1 h4 y17 ff1 fs0 fc0 sc0 ls0 ws0">for i=1:256</div><div class="t m0 x1 h4 y18 ff1 fs0 fc0 sc0 ls0 ws0"> for j=1:i</div><div class="t m0 x1 h3 y19 ff1 fs0 fc0 sc0 ls0 ws0"> S1(i)=GP(j)+S1(i); <span class="_ _1"></span> %<span class="ff2">&#35745;&#31639;<span class="_ _0"> </span></span>Sk</div><div class="t m0 x1 h4 y1a ff1 fs0 fc0 sc0 ls0 ws0"> end</div><div class="t m0 x1 h4 y1b ff1 fs0 fc0 sc0 ls0 ws0">end</div><div class="t m0 x1 h3 y1c ff1 fs0 fc0 sc0 ls0 ws0">S2=round((S1*256)+0.5); %<span class="_ _1"></span><span class="ff2">&#23558;<span class="_ _0"> </span></span>Sk<span class="_ _0"> </span><span class="ff2">&#24402;&#21040;&#30456;&#36817;&#32423;&#30340;&#28784;&#24230;</span></div><div class="t m0 x1 h4 y1d ff1 fs0 fc0 sc0 ls0 ws0">for i=1:256</div><div class="t m0 x1 h3 y1e ff1 fs0 fc0 sc0 ls0 ws0"> GPeq(i)=sum(GP(-nd(S2==i))); %<span class="_ _1"></span><span class="ff2">&#35745;&#31639;&#29616;&#26377;&#27599;&#20010;&#28784;&#24230;&#32423;&#20986;&#29616;&#30340;&#27010;&#29575;</span></div><div class="t m0 x1 h4 y1f ff1 fs0 fc0 sc0 ls0 ws0">end</div><div class="t m0 x1 h3 y20 ff1 fs0 fc0 sc0 ls0 ws0">-gure,bar(0:255,GPeq,'b') %<span class="_ _1"></span><span class="ff2">&#26174;&#31034;&#22343;&#34913;&#21270;&#21518;&#30340;&#30452;&#26041;&#22270;</span></div><div class="t m0 x1 h3 y21 ff1 fs0 fc0 sc0 ls0 ws0">title('<span class="ff2">&#22343;&#34913;&#21270;&#21518;&#30340;&#30452;&#26041;&#22270;</span>')</div><div class="t m0 x1 h3 y22 ff1 fs0 fc0 sc0 ls0 ws0">xlabel('<span class="ff2">&#28784;&#24230;&#20540;</span>')</div><div class="t m0 x1 h3 y23 ff1 fs0 fc0 sc0 ls0 ws0">ylabel('<span class="ff2">&#20986;&#29616;&#27010;&#29575;</span>')</div><div class="t m0 x1 h3 y24 ff1 fs0 fc0 sc0 ls0 ws0">%<span class="ff2">&#22235;&#65292;&#22270;&#20687;&#22343;&#34913;&#21270;</span></div><div class="t m0 x1 h4 y25 ff1 fs0 fc0 sc0 ls0 ws0">PA=PS;</div><div class="t m0 x1 h4 y26 ff1 fs0 fc0 sc0 ls0 ws0">for i=0:255</div><div class="t m0 x1 h3 y27 ff1 fs0 fc0 sc0 ls0 ws0"> PA(-nd(PS==i))=S2(i+1); %<span class="_ _1"></span><span class="ff2">&#23558;&#21508;&#20010;&#20687;&#32032;&#24402;&#19968;&#21270;&#21518;&#30340;&#28784;&#24230;&#20540;&#36171;&#32473;&#36825;&#20010;&#20687;&#32032;</span></div><div class="t m0 x1 h4 y28 ff1 fs0 fc0 sc0 ls0 ws0">end</div><div class="t m0 x1 h3 y29 ff1 fs0 fc0 sc0 ls0 ws0">-gure,imshow(PA) <span class="_ _1"></span> <span class="_ _2"></span> %<span class="_ _1"></span><span class="ff2">&#26174;&#31034;&#22343;&#34913;&#21270;&#21518;&#30340;&#22270;&#20687;</span></div><div class="t m0 x1 h3 y2a ff1 fs0 fc0 sc0 ls0 ws0">title('<span class="ff2">&#22343;&#34913;&#21270;&#21518;&#22270;&#20687;</span>')</div><div class="t m0 x1 h4 y2b ff1 fs0 fc0 sc0 ls0 ws0">imwrite(PA,'PicEqual.bmp');</div></div></div><div class="pi" data-data='{"ctm":[1.611850,0.000000,0.000000,1.611850,0.000000,0.000000]}'></div></div> </body> </html>
评论
    相关推荐
    • 直方图均衡化.rar
      通过opencv进行图像直方图均衡化,使图像有效信息增强,图像更清晰。
    • 直方图均衡化.zip
      图像直方图均衡化处理算法,MATLAB代码可直接使用
    • 直方图均衡.rar
      手动进行直方图均衡,并且通过峰值信噪比等评价方式进行图像评价
    • 直方图均衡化.zip
      压缩包内包含两个m文件,一个是直方图均衡化,另一个是频域滤波,即对一幅图像进行低通、高通滤波,并且使用高频强调和直方图均衡相结合的方法增强图像;另外包含了四张测试用的图片。
    • 直方图均衡化.rar
      vc++实现直方图均衡化,附带 具体代码
    • 直方图均衡化.zip
      关于图像直方图均衡化的自编代码,可以供初学图像处理者参考。
    • 彩色图像直方图均衡化.zip
      实现对彩色图像的直方图均衡化处理,不能采用封装好的统计直方图和均衡化函数。
    • 直方图均衡化.zip
      基于python语言的不简单使用exposure模块中的equalize_hist()函数来完成直方图均衡化
    • 直方图均衡化.zip
      使用matlab通过循环实现直方图均衡化,以达到对图像的对比进行调整的目的!
    • 直方图均衡化-自实现.rar
      功能:实现直方图均衡化,与MATLAB自带函数histeq对比效果一致