matlab susan,SUSAN算法的matlab代码

%% 时间:2015年5月9日 %% 修改人:961256834(qq) clear all; close all; clc; %% 计时开始 tic; %% 输入图像 imag = imread('girl.bmp'); %% 判断该图像是彩色图像还是灰度图像,如果是彩色图像把它转换为灰度图像 [x,y,z] = size(imag);            if(z~=1)     imag = rgb2gray(imag);    end im = double(imag); lm = zeros(size(im)); T = 10; %% 37像素圆形模板比较 mask = [0 0 1 1 1 0 0; 0 1 1 1 1 1 0; 1 1 1 1 1 1 1; 1 1 1 1 1 1 1; 1 1 1 1 1 1 1; 0 1 1 1 1 1 0; 0 0 1 1 1 0 0]; [a,b] = size(im); for i = 4:a-3     for j = 4:b-3        current_image = im(i-3:i+3,j-3:j+3);        current_masked_image = mask.*current_image;        center = current_masked_image(4,4);          for ii = 1:7                                %统计USAN的面积,将模板内每个像素与中心像素比较             for jj = 1:7                            if (abs(current_masked_image(ii,jj)-center) >= T)                   current_masked_image(ii,jj) = 1;                else                   current_masked_image(ii,jj) = 0;                end             end          end       n = sum(current_masked_image(:));       if(n < 18);           %确定是否为角点           lm(i,j) = im(i,j);               else            lm(i,j) = 0;       end     end end %% 选择计算窗口大小 wf = 32; %% 对候选点进行分割,分割为mf*nf个区域 mf = floor(a/wf); %行数 nf = floor(b/wf); %列数 xc = []; yc = []; for y_unit = 1:mf     for x_unit = 1:nf         %计算分割区域中的最大值         [C,I] = max(lm((y_unit-1)*wf+1:y_unit*wf,(x_unit-1)*wf+1:x_unit*wf));%得到行         [C1,I1] = max(C);%得到列         if(C1 > 0)            IV_crch(y_unit,x_unit) = C1; %得到分割区域中的最大值            row = I(I1);            col = I1;            crch_row(y_unit,x_unit) = (y_unit-1)*wf+row; %得到最大值在候选区域中的行数            crch_col(y_unit,x_unit) = (x_unit-1)*wf+col; %得到最大值在候选区域中的列数            yc=[yc,(y_unit-1)*wf+row];xc = [xc,(x_unit-1)*wf+col];         end     end end %% 计时结束 toc; t = toc; disp(['本程序的运行时间为',num2str(t),'秒。']) %% 先给出原来的图像 figure;imshow(imag);title('原图像');xlabel('横向');ylabel('纵向');axis on; %% 描绘特征点分布 figure;plot(xc,yc,'*');view(0,-90);title('特征点的分布');xlabel('图像的列数');ylabel('图像的行数'); %% 图像中显示特征点 figure;imshow(imag);hold on;plot(xc,yc,'R*');axis on;title('图像中显示特征点');xlabel('图像的列数');ylabel('图像的行数');

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值