资源简介

红外图像自适应对比度增强方法的仿真,绝对的真实。需要自适应修改阈值T和A1,A2的值

资源截图

代码片段和文件信息

img=imread(‘D:\My Documents\桌面\红外小胖哈哈舞\600.jpg‘);
img_gray=rgb2gray(img);
figure (1);imshow(img_gray);
my_hist=imhist(img_gray);

figure(3);plot(my_hist(1:255)‘);    %直方图

L=0;   %统计灰度级数
A1=90;A2=90;   %%%分段 低 常 高温区域
height=240;
width =320;
s_num=height * width;
T=60;     %5阈值大小
max_gray=256;  %图像最高灰度等级


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%灰度标记
ff_x=zeros(1256);
 for i=1:256
  if(my_hist(i1)>T | my_hist(i1)==T)
    ff_x(1i)=1;
    L=L+1;
  end
 end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%计算s1_can、s2_can、s3_can
s1=0;s2=0;s3=0;
for xx=1:A1
    s1=s1+my_hist(xx);
end

for yy=(A1+1):A2
    s2=s2+my_hist(yy);
end

for zz=(A2+1):max_gray
    s3=s3+my_hist(zz);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%
%模式判断
%%%%%%%%%%%%%%%%%%%%%%%%%% 
s1_can=s1/s_num;
s2_can=s2/s_num;
s3_can=s3/s_num;

% if(s1_can>0.8)
%   为低温目标
% end

% if(s2_can>0.8)
%   为常温目标
% end

% if(s3_can>0.8)
%   为高温目标
% end

% if(s1_can+s2_can>0.8)
%   为低温和常温目标
% end

% if(s2_can+s3_can>0.8)
%   为常温和高温目标
% end

% if(s3_can+s1_can>0.8)
%   为高温和低温目标
% end
%s1_can+s2_can+s3_can=1;
%%%%%%%%%%%%%%%%%%%%%%%%%

ref_k=zeros(1max_gray+1);
for j=1:256
  for l=1:j
     ref_k(1j)=ff_x(1l)+ref_k(1j);
  end
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%灰度的等距离排列
his_out=zeros(1256);
for m=1:256
   his_out(1m)=255*ref_k(1m)/L;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I=zeros(240320);   %%初始化

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for iii=1:256
   I_dengji(iii)=iii;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for ii=1:height
   for jj=1:width

      img_gray(iijj)=1+img_gray(iijj);   %%表示等级


     if(ref_k(1I_dengji(img_gray(iijj)))<(A1) | ref_k(1I_dengji(img_gray(iijj)))==A1)
        I(iijj)=s1_can*255*ref_k(1I_dengji(img_gray(iijj)))/A1;
        
     elseif(ref_k(1I_dengji(img_gray(iijj)))>A1 & ref_k(1I_dengji(img_gray(iijj)))==A2)
        I(iijj)=(s2_can*255*(ref_k(1I_dengji(img_gray(iijj)))-A1)/(A2-A1))+s1_can*255;
        
     elseif(ref_k(1I_dengji(img_gray(iijj)))>A2)
        I(iijj)=(s3_can*255*(I_dengji(img_gray(iijj))-A2)/(ref_k(1max_gray)-A2))+(1-s3_can)*255;
     end
     
   end
end 
 I1=round(I);
 figure(2);
 imshow(uint8(I1));
  
 my_hist_1=imhist(uint8(I1));
figure(4);
plot(my_hist_1(1:255));    %直方图
%imshow(my_hist_1);    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2526  2013-07-10 17:31  yizhonghongwaizishiyingduibiduzengqiang.m

----------- ---------  ---------- -----  ----

                 2526                    1


评论

共有 条评论