def crop(img_array, x):
    """
    Crop image.
    the pixel in x with following orders:
      (from_top, from_bottom, from_left, from_right)
    The value is start from the img bounds.
    It could not beyond the shape of image.

    EG. An img with shape (46, 120, 3)
        x = (10, 20, 30, 40)
        return shape (16, 50, 3)
    """
    assert len(x) == 4
    i_h, i_w, i_c = img_array.shape
    top, bottom, left, right = x
    assert 0 <= top
    assert 0 <= left
    assert 0 <= bottom
    assert 0 <= right
    assert i_h > top + bottom
    assert i_w > left + right

    return img_array[top: i_h-bottom, left: i_w-right]