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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:21:04+00:00 2026-06-17T09:21:04+00:00

I am using Ubuntu 12.04 and OpenCV 2 I have written the following code

  • 0

I am using Ubuntu 12.04 and OpenCV 2

I have written the following code :

IplImage* img =0;
img = cvLoadImage("nature.jpg");
if(img != 0)
{
    Mat Img_mat(img);
    std::vector<Mat> RGB;
    split(Img_mat, RGB);

    int data = (RGB[0]).at<int>(i,j)); /*Where i, j are inside the bounds of the matrix size .. i have checked this*/ 
}

The problem is I am getting negative values and very large values in the data variable. I think I have made some mistake somewhere. Can you please point it out.
I have been reading the documentation (I have not finished it fully.. it is quite large. ) But from what I have read, this should work. But it isnt. What is going wrong here?

  • 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-17T09:21:05+00:00Added an answer on June 17, 2026 at 9:21 am

    Img_mat is a 3 channeled image. Each channel consists of pixel values uchar in data type.
    So with split(Img_mat, BGR) the Img_mat is split into 3 planes of blue, green and red which are collectively stored in a vector BGR. So BGR[0] is the first (blue) plane with uchar data type pixels…hence it will be

    int dataB = (int)BGR[0].at<uchar>(i,j);
    int dataG = (int)BGR[1].at<uchar>(i,j);
    

    so on…

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

Sidebar

Related Questions

I am using cvCalcOpticalFlowLK function in my code (OpenCV 2.4.1 and Ubuntu 12.04). I
Using Ubuntu, have the file clhep-2.1.2.4.tgz The instructions say to unwind the source code
I am using Ubuntu 9.04 I have installed the following package versions: unixodbc and
i am using ubuntu 12.04, and i have installed opencv 2.4 (actually, i installed
I am using ubuntu 12.04 and Qt Creator 2.4.1. It builds my C code
I am using ubuntu 12.04 on 64 bit machine, I have this simple C
I'm using Ubuntu and Qt Creator 4 I have a .cpp program in the
I cannot successfully calculate the distance transformation using OpenCV (2.3) on an ubuntu. The
I am using OpenCV 2.3.1 to develop Delaunay triangulation code on NetBeans 6.9 on
I am writing a Opencv C code in eclipse -Ubuntu. I created an executable

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.