def check_input_image_and_label(image_path, label_path):
    """
    check the input image and label, they should have same width, height, and projection
    :param image_path: the path of image
    :param label_path: the path of label
    :return: (width, height) of image if successful, Otherwise (None, None).
    """

    img_obj = RSImageclass()
    if img_obj.open(image_path) is False:
        assert False
    label_obj = RSImageclass()
    if label_obj.open(label_path) is False:
        assert False
    # check width and height
    width = img_obj.GetWidth()
    height = img_obj.GetHeight()
    if width != label_obj.GetWidth() or height != label_obj.GetHeight():
        basic.outputlogMessage("Error, not the same width and height of image (%s) and label (%s)"%(image_path,label_path))
        assert False

    # check resolution
    if img_obj.GetXresolution() != label_obj.GetXresolution() or img_obj.GetYresolution() != label_obj.GetYresolution():
        basic.outputlogMessage(
            "Error, not the same resolution of image (%s) and label (%s)" % (image_path, label_path))
        assert False

    # check projection
    if img_obj.GetProjection() != label_obj.GetProjection():
        basic.outputlogMessage(
            "warning, not the same projection of image (%s) and label (%s)" % (image_path, label_path))
    #     assert False

    return (width, height)
def get_area(img_path):

    valid_pixel_count = RSImage.get_valid_pixel_count(img_path)

    # get resolution
    img_obj = RSImageclass()
    if img_obj.open(img_path) is False:
        return False
    res_x = img_obj.GetXresolution()
    res_y = img_obj.GetYresolution()

    area = abs(res_x*res_y*valid_pixel_count)/pow(10,6)
    return area