MCPcopy Create free account
hub / github.com/apache/singa / crop5

Method crop5

python/singa/image_tool.py:377–405  ·  view source on GitHub ↗

Crop at positions from [left_top, left_bottom, right_top, right_bottom, and center]. Args: patch(tuple): width and height of the result image. num_case: num of cases, must be in [1,5] inplace: inplace imgs or not ( return new_imgs)

(self, patch, num_case=1, inplace=True)

Source from the content-addressed store, hash-verified

375 return new_imgs
376
377 def crop5(self, patch, num_case=1, inplace=True):
378 '''Crop at positions from [left_top, left_bottom, right_top,
379 right_bottom, and center].
380
381 Args:
382 patch(tuple): width and height of the result image.
383 num_case: num of cases, must be in [1,5]
384 inplace: inplace imgs or not ( return new_imgs)
385 '''
386 new_imgs = []
387 positions = [
388 "left_top", "left_bottom", "right_top", "right_bottom", "center"
389 ]
390 if num_case > 5 or num_case < 1:
391 raise Exception('num_case must be in [1,5]')
392 for img in self.imgs:
393
394 if num_case < 5:
395 positions = get_list_sample(positions, num_case)
396
397 for position in positions:
398 new_img = crop(img, patch, position)
399 new_imgs.append(new_img)
400
401 if inplace:
402 self.imgs = new_imgs
403 return self
404 else:
405 return new_imgs
406
407 def crop3(self, patch, num_case=1, inplace=True):
408 ''&#x27;Crop a max square patch of the input image at given position and

Callers 2

crop8Method · 0.95
image_tool.pyFile · 0.80

Calls 3

get_list_sampleFunction · 0.85
appendMethod · 0.80
cropFunction · 0.70

Tested by

no test coverage detected