def flatten_image(image):
    """
    Flat the input 2D image into an 1D image while preserve the channels of the input image
    with shape==[height x width, channels]

    :param image: Input 2D image (either multi-channel color image or greyscale image)
    :type image: numpy.ndarray
    :return: The flatten 1D image. shape==(height x width, channels)
    :rtype: numpy.ndarry
    """
    assert len(image.shape) >= 2, "The input image must be a 2 Dimensional image"
    if len(image.shape) == 3:
        image = image.reshape((-1, image.shape[2]))
    elif len(image.shape) == 2:
        image = image.reshape((-1, 1))
    return image