Hello everyone,
I’m working on a project to detect diseases in leaves by analyzing the color of the leaf tips. Specifically, I am using the HSV color space to detect gray or yellow-gray areas. Below are the characteristics of my images and the details of my approach:
Image Characteristics:
- The images mainly feature green leaves, but some leaves have yellow areas caused by disease.
- The background often contains yellow wood chips, which can interfere with color detection.
- My goal is to detect yellow-gray areas near the leaf tips to determine if the leaves are diseased.
Here is the current function I’m using for detection:
def detect_color_with_three_ranges(image, lower_hsv1, upper_hsv1, lower_hsv2, upper_hsv2, lower_hsv3, upper_hsv3, area_threshold):
hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
mask1 = cv2.inRange(hsv_image, lower_hsv1, upper_hsv1)
mask2 = cv2.inRange(hsv_image, lower_hsv2, upper_hsv2)
mask3 = cv2.inRange(hsv_image, lower_hsv3, upper_hsv3)
combined_mask = cv2.bitwise_or(mask1, mask2)
combined_mask = cv2.bitwise_or(combined_mask, mask3)
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (5, 5))
cleaned_mask = cv2.morphologyEx(combined_mask, cv2.MORPH_CLOSE, kernel)
cleaned_mask = cv2.morphologyEx(cleaned_mask, cv2.MORPH_OPEN, kernel)
contours, _ = cv2.findContours(cleaned_mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
diseased_area = 0
for contour in contours:
area = cv2.contourArea(contour)
if area > area_threshold:
diseased_area += area
is_diseased = diseased_area > area_threshold
return cleaned_mask, is_diseased
Current Challenges:
- Setting HSV Ranges:
- How can I determine effective HSV ranges for detecting gray or yellow-gray areas at the leaf tips?
- The yellow wood chips in the background are often mistaken for diseased areas. How can I effectively separate the background from the leaf?
- Preprocessing Suggestions:
- Are there any preprocessing techniques (e.g., background removal or image enhancement) that can improve detection accuracy?
- Region of Interest:
- I currently focus on the center region of the images to minimize background interference. Are there better methods for isolating the leaf tips for detection?
- Detection Goal:
- The primary goal is to accurately identify yellow-gray areas near the leaf tips while ignoring other areas and the background.
If anyone has experience or suggestions related to HSV range adjustment, preprocessing methods, or background filtering techniques, I would greatly appreciate your help! Thank you!