MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / ResizeTransform

Class ResizeTransform

tensorpack/dataflow/imgaug/transform.py:104–130  ·  view source on GitHub ↗

Resize the image.

Source from the content-addressed store, hash-verified

102
103
104class ResizeTransform(Transform):
105 """
106 Resize the image.
107 """
108 def __init__(self, h, w, new_h, new_w, interp):
109 """
110 Args:
111 h, w (int):
112 new_h, new_w (int):
113 interp (int): cv2 interpolation method
114 """
115 super(ResizeTransform, self).__init__()
116 self._init(locals())
117
118 def apply_image(self, img):
119 assert img.shape[:2] == (self.h, self.w)
120 ret = cv2.resize(
121 img, (self.new_w, self.new_h),
122 interpolation=self.interp)
123 if img.ndim == 3 and ret.ndim == 2:
124 ret = ret[:, :, np.newaxis]
125 return ret
126
127 def apply_coords(self, coords):
128 coords[:, 0] = coords[:, 0] * (self.new_w * 1.0 / self.w)
129 coords[:, 1] = coords[:, 1] * (self.new_h * 1.0 / self.h)
130 return coords
131
132
133class CropTransform(Transform):

Callers 5

get_transformMethod · 0.90
get_transformMethod · 0.85
get_transformMethod · 0.85
get_transformMethod · 0.85
get_transformMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected