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 8211639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:29:44+00:00 2026-06-07T10:29:44+00:00

I am trying to convert a given Mat representing an RGB image with 8-bit

  • 0

I am trying to convert a given Mat representing an RGB image with 8-bit depth to Lab using the function provided in the documentation:

cvtColor(source, destination, <conversion code>);

I have tried the following conversion codes:

CV_RGB2Lab
CV_BGR2Lab
CV_LBGR2Lab

I have received bizarre results each time around, with an “L” value of greater than 100 for some samples, literally <107, 125, 130>.

I am also using Photoshop to check the results – but given that 107 is beyond the accepted range of 0 ≤ L ≤ 100, I can not comprehend what my error is.

Update:
I’ll post my overall results here:
Given an image (Mat) represented by 8-bit BGR, the image can be converted by the following:

cvtColor(source, destination, CV_BGR2Lab);

The pixel values can then be accessed in the following manner:

int step = destination.step;
int channels = destination.channels();
for (int i = 0; i < destination.rows(); i++) {
    for (int j = 0; j < destination.cols(); j++) {
        Point3_<uchar> pixelData;
        //L*: 0-255 (elsewhere is represented by 0 to 100)
        pixelData.x = destination.data[step*i + channels*j + 0];
        //a*: 0-255 (elsewhere is represented by -127 to 127)
        pixelData.y = destination.data[step*i + channels*j + 1];
        //b*: 0-255 (elsewhere is represented by -127 to 127)
        pixelData.z = destination.data[step*i + channels*j + 2];
    }
}
  • 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-07T10:29:45+00:00Added an answer on June 7, 2026 at 10:29 am

    That’s because L value is in range [0..255] in OpenCV. You can simply scale this value to needed interval ([0..100] in your case).

    • 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 an array of the RECT structure (given below) into
i´m using subsonic 3 trying convert a SQL2008 project to MySQL. when the projects
Trying to convert my local SVN repo to Git using svn2git as suggested by
I am trying to make a simple program to convert time given in seconds
Using foundation and cocoa frameworks on Mac, I am trying to convert an NSData
I've been trying using array_map to convert characters to HTML entities with htmlentities() like
I am trying to convert the code snippet given in this http://www.movable-type.co.uk/scripts/latlong.html into java.
I'm trying to convert a byte[] to an image in C#. I know this
I'm trying to convert a bit of VC 6.0 C++ code to C#. Specifically,
I am trying to convert all files in a given directory with suffix .foo

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.