-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilterFeaturesGreenPoint.m
32 lines (27 loc) · 1.06 KB
/
filterFeaturesGreenPoint.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function [ filteredPoints, left,right,top,bottom,regionImage ] = filterFeaturesGreenPoint( image,points )
% get rectagle from green point
[region,region2,regionImage] = largestGreenRegion(image);
rectangleSize=160;
translation = [0,-20]; %move up 20 pixel
x=0;y=0;
if size(region2,1)==0 && size(region2,2)==0
x = region.Centroid(1);
y = region.Centroid(2);
else
x = (region.Centroid(1) * region.Area + region2.Centroid(1) * region2.Area) / (region.Area + region2.Area);
y = (region.Centroid(2) * region.Area + region2.Centroid(2) * region2.Area) / (region.Area + region2.Area);
end
x=round(x); y=round(y);
left =x-rectangleSize/2 + translation(1);
right = x+rectangleSize/2 + translation(1);
top = y-rectangleSize/2 + translation(2);
bottom = y+rectangleSize/2 + translation(2);
filteredPoints=SURFPoints(); %initialize filteredPoints as a empty SURFPoints class
for i=1:length(points)
x=points.Location(i,1);
y=points.Location(i,2);
if x>=left && x<=right && y>=top && y<=bottom
filteredPoints = [filteredPoints; points(i)];
end
end
end