def build_vector(image, binary=True):
    """
    图像转一维特征向量
    :param image: pillow Image object with mode 1 or mode L
    :param binary: 黑白图是否生成为0，1向量
    :return: list of int
    """
    vector = []
    for pixel in image.getdata():
        if binary:
            vector.append(1 if pixel == 255 else 0)
        else:
            vector.append(pixel)
    return vector