What is My Issue?
I have generated depth maps from monocular images using DenseDepth. Some of my results are below. I need help masking the darkest shades/ the darkest value of greys in a given range in the depth map.
I would like to be able to give two hex values ie. #6E6E6E and #000000 and for the mask to select all the values in-between and then generate a black and white mask.
What Have I Tried?
After some research I came across this here: https://medium.com/@offsouza/segmentando-objetos-pela-cor-opencv-487d5181b473 (Use on Chrome for Google Translate as it is in Spanish I think)
Here is the depth map which I tried to use in this specific example:
Here is the python code which I used:
import cv2
import numpy as np
image = cv2.imread('DepthMap.png')
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
blur = cv2.medianBlur(hsv ,11)
lower = np.array([0,0,35])
upper = np.array([0,0,44])
mask = cv2.inRange(blur, lower, upper)
res = cv2.bitwise_and(image,image, mask= mask)
cv2.imshow("mask ",mask)
cv2.imshow('stack', np.hstack([image, res]))
cv2.waitKey(0)
This is the output of the code:
This doesn't ,however, allow me to give two hex values and then select everything in-between but instead I need to specify the upper and lower values. To do this I used this script here: https://github.com/offsouza/color-segmentation/blob/master/get_color.py.
As you can probably tell, this isn't the best result- at all- to the extent that it doesn't work. I have very little knowledge in this field so I would really appreciate if you could help me!
Edit: this is a hand drawn representation of an expected outcome:
https://i.ibb.co/n8JkSf3/C051-EAE8-C114-4-E90-8938-25-A8-C79-A4-A7-E.jpg