I'm trying to segment the blue and black line of this image.
but I was unable to segment them separately (using the OpenCV library in Java) and it resulted in this:
I tried this function:
mgproc.threshold(imgGray, imgThreshold, 0, 255, Imgproc.THRESH_BINARY + Imgproc.THRESH_OTSU);
How can I segment the blue and black lines separately using the OpenCV library?
If the colors of the lines are a given, you can define a color range and filter the image.
Here is a sample code (not mine; taken from this website: https://pythonprogramming.net/color-filter-python-opencv-tutorial/)
lower_red = np.array([30,150,50])
upper_red = np.array([255,255,180])
mask = cv2.inRange(hsv, lower_red, upper_red)
res = cv2.bitwise_and(frame,frame, mask= mask)
cv2.imshow('frame',frame)
cv2.imshow('mask',mask)
cv2.imshow('res',res)