MCPcopy Create free account
hub / github.com/PyImageSearch/imutils / resize

Function resize

imutils/convenience.py:65–94  ·  view source on GitHub ↗
(image, width=None, height=None, inter=cv2.INTER_AREA)

Source from the content-addressed store, hash-verified

63 return cv2.warpAffine(image, M, (nW, nH))
64
65def resize(image, width=None, height=None, inter=cv2.INTER_AREA):
66 # initialize the dimensions of the image to be resized and
67 # grab the image size
68 dim = None
69 (h, w) = image.shape[:2]
70
71 # if both the width and height are None, then return the
72 # original image
73 if width is None and height is None:
74 return image
75
76 # check to see if the width is None
77 if width is None:
78 # calculate the ratio of the height and construct the
79 # dimensions
80 r = height / float(h)
81 dim = (int(w * r), height)
82
83 # otherwise, the height is None
84 else:
85 # calculate the ratio of the width and construct the
86 # dimensions
87 r = width / float(w)
88 dim = (width, int(h * r))
89
90 # resize the image
91 resized = cv2.resize(image, dim, interpolation=inter)
92
93 # return the resized image
94 return resized
95
96def skeletonize(image, size, structuring=cv2.MORPH_RECT):
97 # determine the area (i.e. total number of pixels in the image),

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…