reader/reader_utils.py
def random_crop(img, h_target, w_target):
    """
    Random crop the image to the target size
    :param img: image to be cropped
    :param h_target: target height
    :param w_target: target width
    :return: random cropped image
    """
    h, w, _ = img.shape
    h_range = h - h_target
    w_range = w - w_target
    if h_range == 0:
        h_start = 0
    else:
        h_start = np.random.randint(0, h_range)
    if w_range == 0:
        w_start = 0
    else:
        w_start = np.random.randint(0, w_range)
    img = img[h_start:h_start+h_target, w_start:w_start+w_target, :]
    return img

    Random crop the image to the target size
    :param img: image to be cropped
    :param h_target: target height
    :param w_target: target width
    :return: random cropped image
    
Random crop the image to the target size
Random crop the image to the target size
def random_crop(img, h_target, w_target):
    h, w, _ = img.shape
    h_range = h - h_target
    w_range = w - w_target
    if h_range == 0:
        h_start = 0
    else:
        h_start = np.random.randint(0, h_range)
    if w_range == 0:
        w_start = 0
    else:
        w_start = np.random.randint(0, w_range)
    img = img[h_start:h_start+h_target, w_start:w_start+w_target, :]
    return img
def random_crop ( img , h_target , w_target ) : h , w , _ = img . shape h_range = h - h_target w_range = w - w_target if h_range == 0 : h_start = 0 else : h_start = np . random . randint ( 0 , h_range ) if w_range == 0 : w_start = 0 else : w_start = np . random . randint ( 0 , w_range ) img = img [ h_start : h_start + h_target , w_start : w_start + w_target , : ] return img
Random crop the image to the target size
Random crop the image to the target size
"""
    Random crop the image to the target size
    :param img: image to be cropped
    :param h_target: target height
    :param w_target: target width
    :return: random cropped image
    """
random cropped image
random cropped image
img
image to be cropped
image to be cropped
h_target
None
w_target
None