3

I am trying to crop out the region detected using mser. The mser.detect() function produces mser-regions and I would like to crop this region to give me the resulting output.I am using python and would really appreciate if someone can help in 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]

I wanted to crop it according to the hulls.

zindarod
  • 6,328
  • 3
  • 30
  • 58

1 Answers1

0

You can use mask (in same size with img) which has value 1 if its pixel in hulls, others is 0. Then simply use bitwise_and to crop the hulls you want.

tuan.tran
  • 1,781
  • 15
  • 21