⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 helpme.m

📁 10個MATLAB處理運算方法,影像強化灰階二值等,看看
💻 M
字号:
clear;
clc;
GrayThreshold=60;
FileName = input('Enter your picture file name: ','s');
x=[];
map=[];
[x,map]=imread(FileName,'bmp');
%======================================================================
%Binary
I=rgb2gray(x);
t=255;
f=0;
[rows,columns]=size(I);
for i=1:1:rows
   for j=1:1:columns
      if I(i,j)>=GrayThreshold
         I(i,j)=t;
      else
         I(i,j)=f; 
      end   
   end
end 

%======================================================================
istart=100;
iend=200;
jstart=50;
jend=150;
%======================================================================
%Horizontal statistic plot
for i=istart:iend
    func1(i)=sum(I(i,jstart:jend));
end
m=0;
s=func1(istart);
for i=istart+1:1:iend
   if func1(i)<s
      s=func1(i);
      m=i;
   end
end
%axis([istart iend 0 100]);
%figure(1);
%plot(func1);
%======================================================================
%Vertical statistic plot
for j=jstart:jend
      func2(j)=sum(I(istart:iend,j));
end
n=0;
t=func2(jstart);
for j=jstart+1:1:jend
   if func2(j)<t
      t=func2(j);
      n=j;
   end
end
%axis([jstart jend 0 100]);
%figure(2);
%plot(func2);
%======================================================================
%find pupil area
AT=25;
p=0;
for i=m-AT:1:m+AT
   for j=n-AT:1:n+AT
      if I(i,j)==0
         p=p+1;
      end
   end
end
disp('pupil area = ');
disp(p);
%======================================================================
A=I(m-AT:m+AT,n-AT:n+AT);
figure(3);
imshow(A);
%=======================================================================
disp('m = ');
disp(m);
disp('n = ');
disp(n);

⌨️ 快捷键说明

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