priwittclock.m
上传用户:jiaji168
上传日期:2016-05-12
资源大小:816k
文件大小:1k
源码类别:

图形图像处理

开发平台:

Matlab

  1. I=imread('CLOCK.bmp');
  2. I=im2double(I);
  3. %figure;
  4. %imshow(I);title('org img');
  5. [height width R]=size(I);
  6. for i=2:height-1
  7.     for j=2:width-1
  8.         Dx=[I(i+1,j-1)-I(i-1,j-1)]+[I(i+1,j)-I(i-1,j)]+[I(i+1,j+1)-I(i-1,j+1)];
  9.         Dy=[I(i-1,j+1)-I(i-1,j-1)]+[I(i,j+1)-I(i,j-1)]+[I(i+1,j+1)-I(i+1,j-1)];
  10.        P(i,j)=sqrt(Dx^2+Dy^2);
  11.      
  12.     end
  13. end
  14. %figure;
  15. %imshow(P,[]);
  16. for i=1:height-1
  17.     for j=1:width-1
  18.         if (P(i,j)<0.4)
  19.             P(i,j)=1;
  20.         else P(i,j)=0;
  21.         end
  22.     end
  23. end
  24. figure;
  25. imshow(P,[]);