autobright.htm

来自「matlab图象增强代码集合。多个代码。英文。」· HTM 代码 · 共 67 行

HTM
67
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312"></HEAD>
<BODY><PRE>%    AUTOBRIGHT:Automatically adjusts the brightness level of images
%
%           ***    Made by me and my name is DIVAKAR ROY    ******
%                   residing presently in   NAGPUR,INDIA 
%          I am a B.E. graduate(ELECTRONICS AND TELECOMMUNICATION)

function autobright
warning off
%==========================================================================
[FileName,PathName] = uigetfile('*.jpg','Select any image');
y= [PathName,FileName];
img=imread(y);
[m1 n1 r1]=size(img);
%==========================================================================
if(r1==3)
    a=rgb2ntsc(img);
end
if(r1==1)
    a=double(img)./255;
end
[m1 n1 r1]=size(a);
limit=mean(mean(a(:,:,1)));
my_limit=0.5;
limca=my_limit-limit;
%==========================================================================
for(i=1:m1)
    for(j=1:n1)
          if(limca&lt;0)
            if(a(i,j,1)&lt;=0.92)
               a(i,j,1)=a(i,j,1)+limca;
            end
          end
          if(a(i,j,1)&gt;1)
              a(i,j,1)=1;
          end
          if(a(i,j,1)&lt;0)
              a(i,j,1)=0;
          end
      end
end
%==========================================================================
if(r1==3)
    image=ntsc2rgb(a);
end
if(r1==1)
    image=a;
end
image=image.*255;
image=round(image);
image=uint8(image);
%==========================================================================
[FileName,PathName] = uiputfile('*.jpg','Select any name for its image');
FileName=[FileName '.jpg'];
y= [PathName,FileName];
imwrite(image,y);
imshow(image)
%==========================================================================





</PRE></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?