I have some GPR (ground-penetrating RADAR) data set in .jpg format[Imge attached]. Need to read them and feed them to an Excel sheet. I need each color's rectangle length by pixel value to process the data further. The color detection and precise length of their rectangles are required as an output. Original image to be processed
My plan is to detect the color by passing it through several color filters and then creating a bounding box around them to get their length. I have tried to re-adjust the HSV value several times but colors are not getting detected properly. Here is a code to filter only the red color rectangles from these images.
import cv2import numpy as np# Load the imageimage = cv2.imread('Image15.jpg')# Convert BGR to HSVhsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)# Define the range of red color in HSVlower_red = np.array([0, 50, 50])upper_red = np.array([10, 255, 255])# Threshold the HSV image to get only red colorsmask = cv2.inRange(hsv, lower_red, upper_red)# Bitwise-AND mask and original imagefiltered_image = cv2.bitwise_and(image, image, mask=mask)# Display the original and filtered imagescv2.imshow('Original Image', image)cv2.imshow('Filtered Image', filtered_image)cv2.waitKey(0)cv2.destroyAllWindows()
It has missed some of the blocks on the left side and some at the center. But I really can't understand the unpredictability of this filter. Please guide me on how I can precisely detect the colored rectangles' lengths.