imresize¶
tiatoolbox.utils.transforms.imresize
- imresize(img, scale_factor=None, output_size=None, interpolation='optimise')[source]¶
Resize input image.
- Parameters
img (
numpy.ndarray) – input imagescale_factor (tuple(float)) – scaling factor to resize the input image
output_size (tuple(int)) – output image size, (width, height)
interpolation (str or int) – interpolation method used to interpolate the image using opencv interpolation flags default=’optimise’, uses cv2.INTER_AREA for scale_factor <1.0 otherwise uses cv2.INTER_CUBIC
- Returns
resized image
- Return type
Examples
>>> from tiatoolbox.wsicore import wsireader >>> from tiatoolbox.utils import transforms >>> wsi = wsireader.WSIReader(input_path="./CMU-1.ndpi") >>> slide_thumbnail = wsi.slide_thumbnail() >>> # Resize the image to half size using scale_factor 0.5 >>> transforms.imresize(slide_thumbnail, scale_factor=0.5)