Shortcuts

Resize

class mmocr.datasets.transforms.Resize(scale=None, scale_factor=None, keep_ratio=False, clip_object_border=True, backend='cv2', interpolation='bilinear')[source]

Resize image & bboxes & polygons.

This transform resizes the input image according to scale or scale_factor. Bboxes and polygons are then resized with the same scale factor. if scale and scale_factor are both set, it will use scale to resize.

Required Keys:

  • img

  • img_shape

  • gt_bboxes

  • gt_polygons

Modified Keys:

  • img

  • img_shape

  • gt_bboxes

  • gt_polygons

Added Keys:

  • scale

  • scale_factor

  • keep_ratio

Parameters
  • scale (int or tuple) – Image scales for resizing. Defaults to None.

  • scale_factor (float or tuple[float, float]) – Scale factors for resizing. It’s either a factor applicable to both dimensions or in the form of (scale_w, scale_h). Defaults to None.

  • keep_ratio (bool) – Whether to keep the aspect ratio when resizing the image. Defaults to False.

  • clip_object_border (bool) – Whether to clip the objects outside the border of the image. Defaults to True.

  • backend (str) – Image resize backend, choices are ‘cv2’ and ‘pillow’. These two backends generates slightly different results. Defaults to ‘cv2’.

  • interpolation (str) – Interpolation method, accepted values are “nearest”, “bilinear”, “bicubic”, “area”, “lanczos” for ‘cv2’ backend, “nearest”, “bilinear” for ‘pillow’ backend. Defaults to ‘bilinear’.

Return type

None

transform(results)[source]

Transform function to resize images, bounding boxes and polygons.

Parameters

results (dict) – Result dict from loading pipeline.

Returns

Resized results, ‘img’, ‘gt_bboxes’, ‘gt_polygons’, ‘scale’, ‘scale_factor’, ‘height’, ‘width’, and ‘keep_ratio’ keys are updated in result dict.

Return type

dict

Read the Docs v: dev-1.x
Versions
latest
stable
v1.0.1
v1.0.0
0.x
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
v0.4.1
v0.4.0
v0.3.0
v0.2.1
v0.2.0
v0.1.0
dev-1.x
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.