def calculate_offset(img, left_fitx, right_fitx):
    """
        function to calculate offset from center of lane
        Args:
            left_fitx, right_fitx: the fit pixels on the x axis
        Returns:
            the offset calculation
    """
    # pixel lane width according to right - left fit pixels
    lane_width_pixels = abs(left_fitx[-1] - right_fitx[-1])
    # lane center according to fit
    lane_center_x = (left_fitx[-1] + right_fitx[-1])//2
    # distance from center of lane in pixels
    pixel_offset_from_center = img.shape[1]//2 - lane_center_x

    # expected lane width
    lane_width_m = 3.7
    # return the offset
    return lane_width_m * (pixel_offset_from_center/lane_width_pixels)