SS(selective search) and Graph Based Image Segmentation
阿新 • • 發佈:2018-11-17
用處:避免滑動視窗暴力窮舉列出所有區域
SS演算法流程
其中分割演算法執行結果:
分割演算法執行結果:
SS執行結果:
import skimage.data import selectivesearch import cv2 as cv ''' img : ndarray image with region label region label is stored in the 4th value of each pixel [r,g,b,(region)] regions : array of dict [ { 'rect': (left, top, width, height), 'labels': [...], 'size': component_size }, ... ] ''' img = cv.imread('house.jpg') img_lbl, regions = selectivesearch.selective_search(img, 500, 0.8, 10) for region in regions: x, y, w, h = region['rect'] rect = cv.rectangle(img, (x, y), (x+w, y+h), (0, 0, 255), 1) cv.imshow("test", img) print("number of Boxes %d" % len(regions)) cv.waitKey(0)