Jump to content

How do I convert RGB pixel intensity to its grayscale intensity


Recommended Posts

I have to convert RGB pixel intensity to its grayscale intensit. Is it possible to convert it using LV functions?

The most simple solution is to simply add the R, G, and B parts together and divide it by 3. This has however likely the effect of not exactly giving the result you would expect since the human eye sensitivity is different for the different colors. So you would have to weight the different colors accordingly before adding them. I think you will end up with weighting factors around 0.8 .. 1.3 for the different colors, but I haven't the exact information ready here. Looking on internet about color to grayscale conversion should give you the details easily and you may find that there are actually different weighting factors depending on your intended application.

Rolf Kalbermatter

Link to comment
try it (вроде работает :) )

I do not know how "correct" my method is but I'll share it for the sake of conversation.

I deal with the three color components like the like they are vectors in color space.

To get a gey scale representation I take the square root of the sum of the three components squared and then divide by the max possible vector length (sqrt [ 3 X 255^2]).

the result of that value becomes the new R, G, and B values.

Ben

Link to comment
I do not know how "correct" my method is but I'll share it for the sake of conversation.

I deal with the three color components like the like they are vectors in color space.

To get a gey scale representation I take the square root of the sum of the three components squared and then divide by the max possible vector length (sqrt [ 3 X 255^2]).

the result of that value becomes the new R, G, and B values.

Ben

Grey shade GREY it RGB with components (GREY, GREY, GREY). Therefore the algorithm (formula) for three numbers (R, G, B) and GREY is important. Frequently use (processing of digitalimaging) formulas (http://neuroface.narod.ru/files/mahfoudh_autoref.pdf)

(1) grey=0.3*R+0.59*G+0.11*B

Or

(2) grey = (R+G+B)/3

(if R, G, B, GREY = [0,1])

Results are lower.

0-initial picture

1-calculation under the formula (1)

2-calculation under the formula (2)

(since I lazy my example uses interpolation from labview above :) )

post-4964-1147217943.gif?width=400

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.