-
Notifications
You must be signed in to change notification settings - Fork 0
/
feature_loc.py
68 lines (59 loc) · 1.87 KB
/
feature_loc.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/opt/local/bin/env python
import sys
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
def circle(radius,angle,h,k):
return h+radius*np.cos(angle), k+radius*np.sin(angle)
filename = "/Users/shibombasu/Documents/R_program/BMIcourse/cars_markus/training_car_imgs/image_0001.jpg"
im = Image.open(filename)
im = np.array(im)
print im.shape
theta = np.arange(0,6.28,0.01)
r = 10; h = 199; k = 85;
x, y = np.ogrid[0:384, 0:512]
mask1 = np.ogrid[100:130,30:70]
mask = ((y-h)**2 + (x-k)**2) <= r**2
'''
im1 = im[mask]
im[mask] = 0
im[mask1] = 0
print im1
'''
'''
for i in range(idx[0].size):
for j in range(idx[1].size):
nose += im[x[i],y[j],1]
print nose
'''
plt.figure(1)
plt.imshow(im)
plt.plot(*circle(r,theta,h,k), color='r')
plt.plot(*circle(r, theta, 533, 207), color='r')
plt.plot(*circle(r, theta, 754, 48), color='r')
plt.plot(*circle(r, theta, 525, 50), color='r')
plt.plot(*circle(r, theta, 325, 454), color='r')
plt.plot(*circle(r, theta, 355, 463), color='r')
plt.plot(*circle(r, theta, 650, 469), color='r')
plt.plot(*circle(r, theta, 764, 470), color='r')
plt.plot(*circle(r, theta, 99, 460), color='r')
plt.plot(*circle(r, theta, 103, 397), color='r')
plt.plot(*circle(r, theta, 700, 345), color='r')
plt.plot(*circle(r, theta, 222, 272), color='r')
plt.plot(*circle(r, theta, 391, 342), color='r')
plt.plot(*circle(r, theta, 442, 288), color='r')
plt.plot(*circle(r, theta, 555, 526), color='r')
plt.plot(*circle(r, theta, 861, 538), color='r')
plt.plot(*circle(r, theta, 654, 272), color='r')
plt.plot(*circle(r, theta, 476, 172), color='r')
plt.plot(*circle(r, theta, 440, 220), color='r')
plt.plot(*circle(r, theta, 438, 118), color='r')
plt.plot(*circle(r, theta, 400, 540), color='r')
plt.plot(*circle(r, theta, 452, 405), color='r')
plt.plot(*circle(r, theta, 857, 220), color='r')
plt.show()
'''
#plt.figure(2)
#plt.imshow(im1)
#plt.show()
'''