I am working on an industrial project where my task is to automatically generate two paths that can connect the conduction wire from left to right sides as shown in attached Figure 1. I have successsfuly achieved the target and obtained the lines automatically. But I want to run my code on all images. So, I got stuck on one part to make it applicable on all images without manually changing any input values.
I want to separte two colors (as shown in cropped figures). I have automatically generated cropped images so that i will be left with only two colors to separte. And I can separte these two colors using RGB based thresholding, HSV segmentation, LAB, color difference, otsu method, thresholding based approaches. In the below mentioned code I have done RGB based thresholding to obtain the threshold image. But the problem I am facing is that I need to threshold all images using same approach and same value. And these approaches gives desired result only by changing different values for different images. And I am having sround 1000s of images.
As I can observe and checked that background (Brown in color) is having different values than green part. But I am not able to remove that part and only extract green boundaries. As I am learning Matlab programming step by step. So, I am not able to achieve this task. I have attached few original and cropped images for your reference.
Can anyone please help me to achieve my task. As I am not able to think any of the methods and got badly stuck in this part and rest is all done.
Thank you for your time and support!!
OriginalPicture = imread('D:\test\14H17\18.jpg');
binaryImage = R > 130 & R < 150 & G > 150 & G < 180 & B > 110 & B < 150;