If the pixel is in a region of uniform intensity, then the nearby patches will look similar. If the pixel is on an edge, then nearby patches in a direction perpendicular to the edge will look quite different, but nearby patches in a direction parallel to the edge will result only in a small change. If the pixel is on a feature with variation in all directions, then none of the nearby patches will look similar.
The corner strength is defined as the smallest SSD between the patch and its neighbors (horizontal, vertical and on the two diagonals). If this number is locally maximal, then a feature of interest is present.
As pointed out by Moravec, one of the main problems with this operator is that it is not isotropic: if an edge is present that is not in the direction of the neighbours, then it will not be detected as an interest point.
Source:http://www.cim.mcgill.ca/~dparks/CornerDetector/mainMoravec.htmDenote the image intensity of a pixel at (x, y) by I(x, y).
Input: grayscale image, window size, threshold T
Output: map indicating position of each detected corner1. For each pixel (x, y) in the image calculate the intensity variation from a shift (u, v) as:
where the shifts (u,v) considered are:
(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)2. Construct the cornerness map by calculating the cornerness measure C(x, y) for each pixel (x, y):
3. Threshold the interest map by setting all C(x, y) below a threshold T to zero.
4. Perform non-maximal suppression to find local maxima.
All non-zero points remaining in the cornerness map are corners.
Matlab Code:
% calculate moravec operator of an image
function [corner,ch,cv,cd1,cd2] = cornerMoravec(I,border)
hori = [1 -1];
vert = hori';
diag1 = [1 0; 0 -1];
diag2 = [0 1; -1 0];
average = ones(4,4); % average filter
conv_type='same';
h = conv2(I,hori,conv_type);
v = conv2(I,vert,conv_type);
d1 = conv2(I,diag1,conv_type);
d2 = conv2(I,diag2,conv_type);
c=zeros(size(I));
for i=1:prod(size(I))
c(i) = min([h(i)^2 v(i)^2 d1(i)^2 d2(i)^2]);
end
for i=2:size(I,1)-1
for j=2:size(I,2)-1
hh = sum(sum(abs(h(i-1:i+1,j-1:j+1)))); % 3x3 subimage
vv = sum(sum(abs(v(i-1:i+1,j-1:j+1)))); % 3x3 subimage
dd1 = sum(sum(abs(d1(i-1:i+1,j-1:j+1)))); % 3x3 subimage
dd2 = sum(sum(abs(d2(i-1:i+1,j-1:j+1)))); % 3x3 subimage
c(i,j) = min(hh,min(vv,min(dd1,dd2)));
ch(i,j) = hh;
cv(i,j) = vv;
cd1(i,j) = dd1;
cd2(i,j) = dd2;
end
end
corner=c;
corner=corner(border+1:end-border,border+1:end-border);
ch = ch(border+1:end-border,border+1:end-border);
cv = cv(border+1:end-border,border+1:end-border);
cd1 = cd1(border+1:end-border,border+1:end-border);
cd2 = cd2(border+1:end-border,border+1:end-border);
.
This comment has been removed by the author.
ReplyDeletehello,
ReplyDeletewhat do you mean by
conv_type='same';
am sorry may be u find my quation a little bit wirred but actually am a novice in Matlab !!
ReplyDeletelool fine :D I found the answer on help of matlab
ReplyDeletesameReturns the central part of the convolution of the same size as A.