... <dependencies> ... <dependency> <groupId>com.twelvemonkeys.imageio</groupId> <artifactId>imageio-jpeg</artifactId> <version>3.3.1</version> <!-- Alternatively, build your own version --> </dependency> <dependency> <groupId>com.twelvemonkeys.imageio</groupId> <artifactId>imageio-tiff</artifactId> <version>3.3.1</version> <!-- Alternatively, build your own version --> </dependency> </dependencies>
Yale人脸数据库在人脸识别论文中频繁用到,因此做人脸识别这方面研究还是存一份这个数据库以备用。在网上可以很容易下载这个数据库,我在浙大蔡登教授的主页上下载了这个数据库(Four face databases in matlab format),主页上这个数据库有两种大小可以选择下载,一个是图像大小是32x32的数据库,另一个是64x64,本文选择的是32x32。
数据集说明
主页上有对这个数据集说明:
Contains 165 grayscale images in GIF format of 15 individuals. There are 11 images per subject, one per different facial expression or configuration: center-light, w/glasses, happy, left-light, w/no glasses, normal, right-light, sad, sleepy, surprised, and wink.
Y = zeros(faceH*ShowLine, faceW*numPerLine); for i=0:ShowLine-1 for j=0:numPerLine-1 Y(i*faceH+1:(i+1)*faceH, j*faceW+1:(j+1)*faceW) = reshape(fea(i*numPerLine+j+1,:), [faceH, faceW]); end end
根据《Hadoop权威指南》中例子使用python来实现 Max Temperature 这个程序,要分别实现Map函数以及Reduce函数。
Map函数
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/env python
import re import sys
for line in sys.stdin: val = line.strip() (year, temp, q) = (val[15:19], val[87:92], val[92:93]) if (temp != "+9999"and re.match("[01459]", q)): print"%s\t%s" % (year, temp)
Reduce函数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/env python
import sys
(last_key, max_val) = (None, -sys.maxint) for line in sys.stdin: (key, val) = line.strip().split("\t") if last_key and last_key != key: print"%s\t%s" % (last_key, max_val) (last_key, max_val) = (key, int(val)) else: (last_key, max_val) = (key, max(max_val, int(val)))