Ask Your Question
0

OpenCV SelectiveSearch Segmentation

asked 2020-10-15 05:55:31 -0600

StefanCepa995 gravatar image

Hi,

I am trying to use OpenCV (4.1.2) SelectiveSearch segmentation in order to generate ROI proposals for really large images (e.g. 5000x4000). Following code takes too much time to process one image:

  print("[INFO]: Calculating candidate region of interest using Selective Search ...")  
  ss = cv2.ximgproc.segmentation.createSelectiveSearchSegmentation()
  ss.setBaseImage(img_0)
  ss.switchToSelectiveSearchFast()
  rects = ss.process()

  print("[INFO]: Found {} candidate region of interests".format(len(rects)))
  proposed_rects =[]
  for (x, y, w, h) in rects:
    proposed_rects.append((x, y, x + w, y +h))

As you can assume, I am using Python. Any suggestions in which I could increase performance of my results?

I am using this for Medical Images, so if there is any suggestion what can I do to tweak perforamnce of generating better ROI proposals I would love to hear it. Doesnt have to be selective search.

edit retag flag offensive close merge delete

Comments

whoa, 5000x4000 is really large, and it's taking a few minutes here on VGA , already

it's a bit unclear what "ROI proposals" (for what ?) means, can you explain ?

can you get away with upscaling ROIs taken from a resized (smaller) image ?

there's also the hfs module in contrib and maybe you can find a pretrained ENet (cnn segmentation) model for medical stuff..

berak gravatar imageberak ( 2020-10-15 07:05:35 -0600 )edit

Try this:

import cv2
import random

image = cv2.imread("deer.jpg")
print("[INFO]: Calculating candidate region of interest using Selective Search ...")  
ss = cv2.ximgproc.segmentation.createSelectiveSearchSegmentation()
ss.setBaseImage(image)
ss.switchToSelectiveSearchQuality()
rects = ss.process()

print("[INFO]: Found {} candidate region of interests".format(len(rects)))
for i in range(0, len(rects)):
    output = image.copy()
    for (x, y, w, h) in rects[i:i]:
        color = [random.randint(0, 255) for j in range(0, 3)]
        cv2.rectangle(output, (x, y), (x + w, y + h), color, 2)

    cv2.imshow("Deer Image", output)
    key = cv2.waitKey(0)  

    if key == ord("q"):
        break
supra56 gravatar imagesupra56 ( 2020-10-15 08:41:00 -0600 )edit
1

U will have to downsized as @berak stating. I do not have 5kx4k. @berak, the link isn't working.

supra56 gravatar imagesupra56 ( 2020-10-15 08:42:56 -0600 )edit
1

@supra56 - link updated, thanks for notice

berak gravatar imageberak ( 2020-10-15 09:17:25 -0600 )edit

Can u post image 5kx4k?

supra56 gravatar imagesupra56 ( 2020-10-15 14:40:46 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2020-10-15 12:38:16 -0600

StefanCepa995 gravatar image

Hi! Thanks for your answer. I will try this out ASAP. And to answer your question, I am trying to build R-CNN network. In order to do that I want to generate ROI proposals based on ANNOTATED training data for building dataset, and later use method that generated ROI proposals for NEW images so that trained network can classify them. Thing is, SelectiveSearch is giving me really poor results.

By poor results I mean that Intersection Over Union with proposed regions and GROUND TRUTH region is never higher then 0.2 (20%).

Any thoughts?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-10-15 05:55:31 -0600

Seen: 968 times

Last updated: Oct 15 '20