".github/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "d07f73003d4d077854869b8f73275657f280334c"
Commit e093bb13 authored by kuonangzhe's avatar kuonangzhe Committed by Kai Chen
Browse files

Update image.md: fix inconsistent API (#19)

Update old crop_img and pad_img to imcrop and impad
parent da39212f
...@@ -116,18 +116,18 @@ mmcv.imflip(img, direction='vertical') ...@@ -116,18 +116,18 @@ mmcv.imflip(img, direction='vertical')
import mmcv import mmcv
import numpy as np import numpy as np
img = mmcv.read_img('tests/data/color.jpg') img = mmcv.imread('tests/data/color.jpg')
# crop the region (10, 10, 100, 120) # crop the region (10, 10, 100, 120)
bboxes = np.array([10, 10, 100, 120]) bboxes = np.array([10, 10, 100, 120])
patch = mmcv.crop_img(img, bboxes) patch = mmcv.imcrop(img, bboxes)
# crop two regions (10, 10, 100, 120) and (0, 0, 50, 50) # crop two regions (10, 10, 100, 120) and (0, 0, 50, 50)
bboxes = np.array([[10, 10, 100, 120], [0, 0, 50, 50]]) bboxes = np.array([[10, 10, 100, 120], [0, 0, 50, 50]])
patches = mmcv.crop_img(img, bboxes) patches = mmcv.imcrop(img, bboxes)
# crop two regions, and rescale the patches by 1.2x # crop two regions, and rescale the patches by 1.2x
patches = mmcv.crop_img(img, bboxes, scale_ratio=1.2) patches = mmcv.imcrop(img, bboxes, scale_ratio=1.2)
``` ```
### Padding ### Padding
...@@ -135,14 +135,14 @@ There are two methods `impad` and `impad_to_multiple` to pad an image to the ...@@ -135,14 +135,14 @@ There are two methods `impad` and `impad_to_multiple` to pad an image to the
specific size with given values. specific size with given values.
```python ```python
img = mmcv.read_img('tests/data/color.jpg') img = mmcv.imread('tests/data/color.jpg')
# pad the image to (1000, 1200) with all zeros # pad the image to (1000, 1200) with all zeros
img_ = mmcv.pad_img(img, (1000, 1200), pad_val=0) img_ = mmcv.impad(img, (1000, 1200), pad_val=0)
# pad the image to (1000, 1200) with different values for three channels. # pad the image to (1000, 1200) with different values for three channels.
img_ = mmcv.pad_img(img, (1000, 1200), pad_val=[100, 50, 200]) img_ = mmcv.impad(img, (1000, 1200), pad_val=[100, 50, 200])
# pad an image so that each edge is a multiple of some value. # pad an image so that each edge is a multiple of some value.
img_ = mmcv.impad_to_multiple(img, 32) img_ = mmcv.impad_to_multiple(img, 32)
``` ```
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment