Ask Your Question
-1

Filter out different colors from image

asked 2017-03-12 08:32:23 -0600

Yothri gravatar image

Hello, I do have the following image. This represents a wheel profile with several colored markings. My aim is to filter out these colored lines, get the color and the position in y coordinate on the wheel. puu.sh/uFthR/4669730c31.bmp

(The image quality is way better in an original image, couldnt upload such a big image)

There can be other colors like red, green blue, yellow, brown, even white, but not black, purple... and so on. Up to 10 different colors.

I would like to create a function where I can put min and max values for RGB and using this range, it should create a mask where I then can use HoughLinesP to get the colored line.

I thought of that as the best way to get these colored lines. If anyone has a better idea on how I could solve this problem, please let me know, I am very new to OpenCV and image processing in general.

I already got some progress on finding at least some of the colors using a post from stackoverflow (I cant post links yet)

But unfortunately I was getting problems already when looking for yellow color lines. Since I also need to find white lines, I am not entirely sure, if this way is the best way to use.

So that is why I ask you guys, if there is maybe a better way on finding different color lines in that kind of image.

Thank you in advance :)

edit retag flag offensive close merge delete

Comments

You can try to sum rows to find color values. Then you can classify pixel

LBerger gravatar imageLBerger ( 2017-03-12 09:52:34 -0600 )edit

Not sure if I got that correctly.

Wouldn't it be enough to convert the Mat to HSV, define two Scalars with min and max Hue Saturation and Value and use inRange to filter the color with the specific range out? Then i should have an image with only the color I specified where i can simply get the line from it? Question is, how accurate is this...

Or is that a waste of time?

Yothri gravatar imageYothri ( 2017-03-12 10:39:30 -0600 )edit

"Waste of time?" I'm agree with you .

LBerger gravatar imageLBerger ( 2017-03-12 11:03:54 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-03-13 05:35:46 -0600

Yothri gravatar image

I did what I just said, defining an upper and a lower Scalar which defines a range for the color I want. Using inrange() i get the mask then. That works for some colors, but for example in HSV color space, red has two color ranges. So I ended up getting 2 masks, and add them together to get red working.

Anyways, if there is someone who has a better solution for this, or more stuff I could try out, please let me know. Also @LBerger, could you explain your first comment a little more? Summing up rows to find color values?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-03-12 08:31:20 -0600

Seen: 1,649 times

Last updated: Mar 12 '17