Skip to content

Commit 6cc74f2

Browse files
committed
figure on image processing
1 parent 56b1e14 commit 6cc74f2

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

images/face0.png

381 KB
Loading

images/face1.png

154 KB
Loading

images/face2.png

339 KB
Loading

images/face3.png

380 KB
Loading

images/face4.png

120 KB
Loading

images/src/faces.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import numpy as np
2+
from scipy import misc
3+
import matplotlib.pyplot as plt
4+
5+
face = misc.face(gray=True)
6+
7+
plt.imshow(face, cmap=plt.cm.gray)
8+
plt.savefig('face0.png')
9+
plt.clf()
10+
11+
bwimage = np.zeros_like(face)
12+
bwimage[face > 128] = 255
13+
plt.imshow(bwimage, cmap=plt.cm.gray)
14+
plt.savefig('face1.png')
15+
plt.clf()
16+
17+
framedface = np.zeros_like(face)
18+
framedface[31:-30, 31:-30] = face[31:-30, 31:-30]
19+
plt.imshow(framedface, cmap=plt.cm.gray)
20+
plt.savefig('face2.png')
21+
plt.clf()
22+
23+
darkface = 255*(face/255)**1.5
24+
plt.imshow(darkface, cmap=plt.cm.gray)
25+
plt.savefig('face3.png')
26+
plt.clf()
27+
28+
sy, sx = face.shape
29+
y, x = np.ogrid[0:sy, 0:sx]
30+
centerx, centery = (660, 300)
31+
mask = ((y - centery)**2 + (x - centerx)**2) > 230**2
32+
face[mask] = 0
33+
plt.imshow(face, cmap=plt.cm.gray)
34+
plt.savefig('face4.png')

0 commit comments

Comments
 (0)