deriv
Contents
open file
clear close all filename = '2015-01-26_18-00-42.JPG'; rgb = imread(filename);
crop
% [rgbc rect] = imcrop(); rect = [2138 782 1396 884]; rgbc = imcrop(rgb,rect); imshow(rgbc); g = rgb2gray(rgbc); im = im2double(g); clear rgb g zm = 0.5;
Warning: Image is too big to fit on screen; displaying at 67%
first moments
m0 = [ 1 2 1; 2 4 2; 1 2 1]; m1 = [ -1 0 1; -2 0 2; -1 0 1]; m2 = [ -1 -2 -1; 0 0 0; 1 2 1]; a0 = imfilter(im,m0); a1 = imfilter(im,m1); a2 = imfilter(im,m2); slope = sqrt(a1.^2 + a2.^2); gmax1 = max(max(slope)); slope = slope/gmax1; imshow(2*slope);
Warning: Image is too big to fit on screen; displaying at 67%
second moments
b11 = imfilter(a1,m1); b22 = imfilter(a2,m2); b12 = imfilter(a1,m2); b21 = imfilter(a2,m1); br = (b11+b22)/2; dmax = max(max(br)); dmin = min(min(br)); gmax2 = max(dmax,-dmin); bipolar_image(2*br/gmax2);
Warning: Image is too big to fit on screen; displaying at 67%
expand laplacian
corner operator
bc = (b11-b22); bs = 2*b12; ac = a1.^2 - a2.^2; as = 2*a1.*a2; e = bc.*as-bs.*ac;
dmax = max(max(e)); dmin = min(min(e)); gmax3 = max(dmax,-dmin); bipolar_image(e/gmax3);
Warning: Image is too big to fit on screen; displaying at 67%
expand corner metric
superimpose corners on image
bipolar_image(e/gmax3,im,0.1);
Warning: Image is too big to fit on screen; displaying at 67%
expand superimposed corner metric
show strongest corners
thresh = 0.2; BW = e > thresh*gmax3; fprintf('count %d\n',sum(sum(BW))); %imshow(~BW); bipolar_image(BW,im,thresh);
count 431 Warning: Image is too big to fit on screen; displaying at 67%
expanded strong corners
deriv matrix
---------------- | a0 | ax | as | ---------------- | ay | br | bs | ---------------- | ac | bc | e | ----------------
[r c] = size(im); data = ones(3*r,3*c); ri = 1:r; ci = 1:c; % column 1 data(ri,ci)=a0/16; data(r+ri,ci)=(a2/3+1)/2; data(2*r+ri,ci)=(ac/9+1)/2; % column 2 data(ri,c+ci)=(a1/3+1)/2; data(r+ri,c+ci)=(br/12+1)/2; data(2*r+ri,c+ci)=(bc/12+1)/2; % column 3 data(ri,2*c+ci)=(as/9+1)/2; data(r+ri,2*c+ci)=(bs/12+1)/2; data(2*r+ri,2*c+ci)=abs(e/20); imshow(imresize(data,1/3));
Warning: Image is too big to fit on screen; displaying at 67%