Facial Detection
#描述#
A classical problem in Computer Vision is Facial Detection. That is to locate a face position in a given image. Among all the methods of facial detection, feature classifier works effectively. Image of human faces always have very distinguished features. For example, pixels of eyes are darker than other parts. We build classifiers for these features. Then, we run images into these classifiers one by one to see whether they are faces. A classifier is simply a rectangle identifier like:
(in the middle and right are two classifiers)
The sum of the pixels which lie within the white rectangles are subtracted from the sum of pixels in the black rectangles. If the result come positive for a classifier, we say: the image can pass this classifier. If an image can pass all the classifiers, this image is confirmed to be a face.
Here, we want you to determine whether a certain area is a human face while given several feature classifiers. To simplify the problem, we only give gray images. Which means every pixel of the image is ranged between [0,255]. An image and a classifier will be given in this way:
#格式#
##输入格式##
w h fw fh
w and h is the width and height of the input image, and fw and fh is the width and height of face area. Then follows a h*w matrix which indicates the input image. Then follows a number u for the
number of classifiers.
Every classifier will be given in one line as:
x1 y1 x2 y2 x3 y3 x4 y4
To simplify the problem, every classifier we give only has one black area and one white area. (x1,y1) is the top left position of the black area while (x2,y2) is the bottom right position. And (x3,y3) is the top left position of the white area while (x4,y4) is the bottom right position. And x is ranged in [0,fw) while y is ranged in [0,fh). These coordinates are relative to face area.
And then follows the request coordinates like:
t rx1 ry1 rx2 ry2 ……
t is the number of request coordinates and (rx,ry) is the upper left position of the request area.
(rx should be ranged in [0,w-fw], and ry should be ranged in [0,h-fh]. if the request area is out of image, you should print “INVALID”)
##输出格式##
For each request, we want you to print “YES” if the area is a face, and “NO” if not. If the request area is out of image, you should print “INVALID”.
There is a blank line between each case. Your program should proceed until the end of input, and each case starts with “CASE n:”, where n is the number of case.
#样例1#
##样例输入1##
22 12 11 12
1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 1 1 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0
2
2 3 8 3 2 4 8 4
1 9 8 9 1 8 8 8
3 0 0 11 0 0 12
4 5 1 2
0 0 0 0
0 1 0 0
0 0 0 0
0 0 0 0
0 0 0 0
1
0 0 0 0 0 1 0 1
2 0 0 1 1
##样例输出1##
CASE 1:
YES
NO
INVALID
CASE 2:
NO
YES
#限制#
1000ms
32768KB
#提示#
#来源#