How to obtain threshold image separating two colors using same approach for all different kind of attached images.
6 views (last 30 days)
Show older comments
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'); %input image
CroppedPicture=imreda('cropped')% Input cropped picture with only two colors
binaryImage = R > 130 & R < 150 & G > 150 & G < 180 & B > 110 & B < 150; % seprate gray color from green to get boundaries
2 Comments
Image Analyst
on 7 Jul 2021
"I have automatically generated cropped images so that i will be left with only two colors to separte." How is that true? From what I see in the tiny little sub images, there are more than 2 colors. Why do you say that you generated cropped images with only 2 colors?
Answers (1)
kanika bhalla
on 7 Jul 2021
Edited: kanika bhalla
on 8 Jul 2021
12 Comments
Doug Hull
on 8 Jul 2021
OK, I have a much clearer idea what you are trying to do.
>>With the help of great people present here in forum. I have already achieved my task.
And with this it looks like you have done this.
What is unclear to me now, is where are the images where this is going wrong?
You are using terminology like "green glass" many if us are not subjuect matter experts in your field. So, this does not mean anything to me.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!