sharpedge.reposition_image ========================== .. py:module:: sharpedge.reposition_image Functions --------- .. autoapisummary:: sharpedge.reposition_image._flip_image sharpedge.reposition_image._rotate_image sharpedge.reposition_image._shift_image_x sharpedge.reposition_image._shift_image_y sharpedge.reposition_image.reposition_image Module Contents --------------- .. py:function:: _flip_image(img, flip) Flips the image based on the specified flip parameter. Private function to be invoked by reposition_image() .. py:function:: _rotate_image(img, rotate) Rotates the image based on the specified rotate parameter. Private function to be invoked by reposition_image() .. py:function:: _shift_image_x(img, shift_x) Shifts the image along the x-axis. Private function to be invoked by reposition_image() .. py:function:: _shift_image_y(img, shift_y) Shifts the image along the y-axis. Private function to be invoked by reposition_image() .. py:function:: reposition_image(img, flip='none', rotate='up', shift_x=0, shift_y=0) Flip, rotate, and shift an image based on the specified requested action. This function allows repositioning of an image by applying one or more transformations (flipping, rotating, and shifting). Each transformation can be controlled by the respective parameters. :param img: The input image as a 2D numpy array (grayscale) or 3D numpy array (RGB). :type img: numpy.ndarray :param flip: Argument used to flip the image. It can be - 'none': No flipping. - 'horizontal': Flip the image horizontally. - 'vertical': Flip the image vertically. - 'both': Flip the image both horizontally and vertically. Default is 'none'. :type flip: str, optional :param rotate: Argument used to rotate the image. It can be - 'up': No rotation. - 'left': Rotate the image 90 degrees counter-clockwise. - 'right': Rotate the image 90 degrees clockwise. - 'down': Rotate the image 180 degrees (flip upside down). Default is 'up'. :type rotate: str, optional :param shift_x: Argument used to shift the image along the x-axis. Default is 0. :type shift_x: int, optional :param shift_y: Argument used to shift the image along the y-axis. Default is 0. :type shift_y: int, optional :returns: The repositioned image that has been flipped, rotated, and/or shifted based on the parameter values. :rtype: numpy.ndarray :raises ValueError: - If the input image is not a 2D or 3D numpy array. - or if the `flip` or `rotate` arguments are invalid. :raises TypeError: If `shift_x` or `shift_y` is not an integer. .. warning:: UserWarning - If the shift values are larger than the image dimensions. - If resizing causes unexpected behavior due to large shifts. .. rubric:: Examples >>> img = np.random.rand(100, 100) >>> repositioned_img = reposition_image(img, flip='horizontal', rotate='left', shift_x=10, shift_y=20) For an RGB image: >>> img_rgb = np.random.rand(100, 100, 3) >>> repositioned_img = reposition_image(img_rgb, flip='both', rotate='down', shift_x=-5, shift_y=10)