Ask Your Question
0

building photoshop-style black-white-conversion

asked 2013-08-25 09:59:48 -0600

efanucar gravatar image

updated 2013-08-26 11:15:21 -0600

Hi all!

I'm trying to separate some coloured object from my background. Before starting with OpenCV I'm using a test image in Photoshop to check which color channels or which combination of color channels are the best.

There is a filter "black-and-white" (which is in fact a grayscale converter) which offers 6 trackbars for each shade of the colors:
red, yellow, green, cyan, blue, magenta
reaching from -200 to +300

I then try to find the best combination of this 6 settings to seperate my object as good as possible (for example the background becomes black, the object white).
If I found the perfect combination, how will an algorithm in OpenCV look to rebuild this gray-scale conversion using the values found in Photoshop?

Thanks and regards!

edit retag flag offensive close merge delete

Comments

1

What OpenCV algorithm are you using? BinaryThreshold? Filter? What have you tried so far?

Jean-François Côté gravatar imageJean-François Côté ( 2013-08-26 06:25:02 -0600 )edit

I already loop through all the pixels and apply a custom grayscale conversion (http://answers.opencv.org/question/12947/custom-grayscale-conversion/) but I want to understand how the weight for R, G and B can be calculated depending on the setting in Photoshop. How to they correspond?

efanucar gravatar imageefanucar ( 2013-09-07 03:18:45 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2013-08-26 20:08:15 -0600

CyberK gravatar image

The conventional way to transfer a RGB image to gray is

Gray = 0.299R + 0.587G + 0.114*B,

which has 3 coefficients to control the final result.

However, I tried the 'black-and-white' filter in Ps and found out it has 6 separate controls. I set red and green channel to 0 but the gray result of yellow, the combination of red and green, remained the same. Therefore I infer this filter is not working in RGB channels. It should be working in HSV, where you can adjust the luminance of one color without affecting the others.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-08-25 09:59:48 -0600

Seen: 923 times

Last updated: Aug 26 '13