3

我正在尝试裁剪使用 mser 检测到的区域。mser.detect() 函数产生 mser 区域,我想裁剪该区域以提供结果输出。我正在使用 python,如果有人可以在 python 中提供帮助,我将不胜感激。

  regions, _ = mser.detectRegions(img)      
  hulls = [cv2.rect(p.reshape(-1, 1, 2)) for p in regions]
  print type(hulls);
  cv2.polylines(vis, hulls, 1, (0, 255, 0))

  #crop_img=[cv2.resize(vis, (b.width, b.height) ,interpolation = cv2.INTER_AREA) for b in bboxes]

我想根据船体裁剪它。

4

1 回答 1

0

您可以使用mask(与 相同大小img)如果其像素在船体中的值为 1,则其他值为 0。然后只需使用bitwise_and来裁剪您想要的船体。

于 2017-11-11T09:04:30.360 回答