def transform_coord(coord, matrix):
    """
    Transforms the given coordinate by the given matrix
    :param coord: The coordinate to transform (tuple (x, y))
    :param matrix: The matrix to transform by (3x3 numpy array)
    :return: The transformed coordinate (tuple (x, y), components casted to ints)
    """
    h0 = matrix[0, 0]
    h1 = matrix[0, 1]
    h2 = matrix[0, 2]
    h3 = matrix[1, 0]
    h4 = matrix[1, 1]
    h5 = matrix[1, 2]
    h6 = matrix[2, 0]
    h7 = matrix[2, 1]
    h8 = matrix[2, 2]

    tx = (h0 * coord[0] + h1 * coord[1] + h2)
    ty = (h3 * coord[0] + h4 * coord[1] + h5)
    tz = (h6 * coord[0] + h7 * coord[1] + h8)
    return int(tx/tz), int(ty/tz)