Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9104083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:46:51+00:00 2026-06-17T01:46:51+00:00

When using RGB values, .NET has built in ways for it to be converted

  • 0

When using RGB values, .NET has built in ways for it to be converted from an integer and it’s straightforward to convert a color to an int. Is there a way of storing LAB colors as integers instead? Unlike RGB, LAB color values can be negative. I don’t want to have to store the colors in RGB and convert them at runtime if I can avoid it as I have no need for RGB values.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:46:52+00:00Added an answer on June 17, 2026 at 1:46 am

    So the transformation being done is RGB -> XYZ with the old 2 degree observer and CIE Standard Illuminant D65 -> CIELAB. The code, for reference, for performing that is given below (R, G, B is assumed to be in [0, 1]).

    Considering these transformations starting from 8 bits per channel in RGB, the range for L* is [0, 100], a* (-85.92, 97.96], b* (-107.54, 94.20]. These values are close approximations. In theory, a* and b* are unbounded, but you will find some places that talk about a limit of +-128, +-110, etc. My suggestion is then to simply sum 128 to each value, multiply it by 100, and then round to integer (that should be precise enough for a color). Any given L*a*b triplet can then be represented by a 16 bits unsigned integer. You could pack them into a 64 bit integer. And after unpacking you would subtract 128 from each value. If you can keep three signed short integers, things get much simpler.

    def rgb_xyz(r, g, b): # 2o. D65
        triple = [r, g, b]
    
        v, d = 0.04045, 12.94
        for i, c in enumerate(triple):
            triple[i] = 100 * (c / d if c <= v else ((c + 0.055)/1.055)**2.4)
    
        multipliers = (
                (0.4124, 0.3576, 0.1805),
                (0.2126, 0.7152, 0.0722),
                (0.0193, 0.1192, 0.9505))
    
        x, y, z = [sum(row[i] * triple[i] for i in range(3))
                for row in multipliers]
        return x, y, z
    
    def xyz_cielab(x, y, z):
        triple = [x, y, z]
    
        t0, a, b = 0.008856, 7.787, 16/116.
        ref = (95.047, 100.0, 108.883)
        for i, c in enumerate(triple):
            triple[i] /= ref[i]
            c = triple[i]
            triple[i] = c ** (1/3.) if c > t0 else a * c + b
    
        l = 116 * triple[0] - 16
        a = 500 * (triple[0] - triple[1])
        b = 200 * (triple[1] - triple[2])
        return l, a, b
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert RGB values to YCbCr color format. using Afroge library.
I am using RGB values of a color from Photoshop and using the same
I have RGB values that I need to convert into CMYK values. I'm using
I've been using a hex calculator to convert hex values to RGB values (
I am using free online sites to select the RGB color . There are
How can I convert RGB values into HTML code? For example, using values like
I'm trying to get rgb color info from every pixel using imagecolorat() and I'm
I'm trying to convert HSB values to RGB values using this algorithm , but
I can get the r,g,b values using the following functions. int rgb=bImg.getRGB(i, j); int
I am using the below code to extract RGB values from images, sometimes this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.