2021年4月8日星期四

Reduce components included by otsu threshold python opencv

I am trying to segment the blue components from a set of images. In most images where blue components have a large spread, otsu thresholded image works properly well. However, for images where blue components are minimal, the results are not ok and seems to include the non-relevant sections. Example below:

enter image description here

Are there ways to improve the otsu thresholding such that only relevant parts are segmented but not necessarily making the other images suffer?

I already tried global and adaptive thresholding but otsu particularly captured betters which however included unnecessary details.

Here's the code:

l_image = remove_background(image)  l_image = cv2.cvtColor(l_image, cv2.COLOR_BGR2GRAY)    ret1,th1 = cv2.threshold(l_image,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)    mask = (th1 != 255)  sel = np.ones_like(image)  sel[mask] = image[mask]  sel = cv2.cvtColor(sel, cv2.COLOR_HSV2BGR)    #we simply set these channels to 0 to remove excess background  sel[:,:,1] = 0  sel[:,:,2] = 0    
https://stackoverflow.com/questions/67015259/reduce-components-included-by-otsu-threshold-python-opencv April 09, 2021 at 12:55PM

没有评论:

发表评论