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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:06:41+00:00 2026-06-05T20:06:41+00:00

I am using OpenCV for some of my image processing related codes. I am

  • 0

I am using OpenCV for some of my image processing related codes. I am stuck at a particular point.

In a particular code, I need to compare the pixel values of an image based on it`s CIE L*a*b* values. I know for BGR we can do something like this :

// img is the image, suppose
uchar *data = ( uchar* )img->imageData;

for(i=0; i< img->height; i++)
    for(j=0; j<img->width; j++)
     {
         b = data[i*img->widthStep + j*img->nChannels + 0];
         g = data[i*img->widthStep + j*img->nChannels + 1];
         r = data[i*img->widthStep + j*img->nChannels + 2]; 
     }

My question is, can we do something similar for l*a*b* color model also ? I mean at first I convert the image by

cvCvtColor(img, lab, CV_BGR2Lab);

then accessing the individual channel info like in the above case (since L*a*b* is also made up of 3 channels, if am not wrong), can we get the pixel values ??

The reason I am asking this is I tried to implement it, but I`m getting some real weird values like very high negative numbers ( I used int datatype instead of uchar since I was unsure about the range ‘a’ and ‘b’ can have ) whereas in Wikipedia I saw that ‘L’ can have values only in the range of 0 to 100. So how exactly can I get those pixel values ??

Thanks in advance !!

  • 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-05T20:06:42+00:00Added an answer on June 5, 2026 at 8:06 pm

    Surely, you can do that, why not? Be aware however, that output is somewhat specific (since a and b can be negative):

    On output 0≤L≤100, -127≤a≤127, -127≤b≤127
    The values are then converted to the destination data type:
        8-bit images:
            L <- L*255/100, a <- a + 128, b <- b + 128
    

    note that L is also scaled to 0-255 range (instead of 0-100). See more here.

    BTW how can you get negative numbers if your data type is unsigned char?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to do some image rectification using OpenCV .I got some code
I am using OpenCV static library in Objective-C to do some image processing, and
I am trying to parallelize some Image Matching code written in OpenCV using TBB.
I'm using ruby-opencv to do some image processing. I have an IplImage object that
I have some (OpenCV) code that generates images. I'm displaying these using OpenGL. When
Im using EMGU (opencv wrapper) for image processing. I want to load images one
I am trying to do some image matching using OpenCV and am using the
I am using Opencv for some real-time video processing. As a front-end I am
I'm using OpenCV for an application in computer vision. I'd like to accelerate some
some (most) of opencv errors are discovered in run time - using CV_64 instead

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.