I'm trying to segregate a tower from its background. To do this I've defined an upper and lower limit HSV range of object color as shown below, but it only segregates partial object from its background, as the object has shades of two different colors, which are grey and white. Is there a possible way to segregate an object containing two different shade colors?
The image is
[![enter image description here][1]][1]
and the code I'm using is:
img = cv2.imread(r'source_img.jpg')
low = np.array([0,0,40])
high = np.array([180,18,230])
hsv = cv2.cvtColor(img,cv2.COLOR_RGB2HSV)
mask = cv2.inRange(hsv,low,high)
masked_img = cv2.bitwise_and(hsv,hsv,mask=mask)
The resultant output image contains only partial object segregation. I want to segregate the full tower excluding background grass, building and sky.
How can I segregate only the object tower without any background?