Shortcuts

mmocr.utils.crop_img

mmocr.utils.crop_img(src_img, box, long_edge_pad_ratio=0.4, short_edge_pad_ratio=0.2)[source]

Crop text region given the bounding box which might be slightly padded. The bounding box is assumed to be a quadrangle and tightly bound the text region.

Parameters
  • src_img (np.array) – The original image.

  • box (list[float | int]) – Points of quadrangle.

  • long_edge_pad_ratio (float) – The ratio of padding to the long edge. The padding will be the length of the short edge * long_edge_pad_ratio. Defaults to 0.4.

  • short_edge_pad_ratio (float) – The ratio of padding to the short edge. The padding will be the length of the long edge * short_edge_pad_ratio. Defaults to 0.2.

Returns

The cropped image.

Return type

np.array

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.