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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:05:13+00:00 2026-06-11T18:05:13+00:00

here’s the problem: I load an grayscale Image with OpenCV v.2.4.2. Now I want

  • 0

here’s the problem: I load an grayscale Image with OpenCV v.2.4.2.
Now I want to know for example value of pixel at position (0,0).
I’ve tried:

Mat image=imread("00001.jpg",1);
cvtColor(image,image,CV_RGB2GRAY);
int a=image.at<unsigned>(0,1);
printf("%d ",a);

This actually doesn’t work. How to get the pixel value with any data type (CV_8U, CV_32S …)?

Thanks!!!

  • 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-11T18:05:14+00:00Added an answer on June 11, 2026 at 6:05 pm

    You are making two mistakes here.

    While reading the image, you are specifying 1 as input arguments. As explained for imread, the function can read image in three different formats.

    CV_LOAD_IMAGE_UNCHANGED (<0) loads the image as is (including the alpha channel if present)
    CV_LOAD_IMAGE_GRAYSCALE ( 0) loads the image as an intensity one
    CV_LOAD_IMAGE_COLOR (>0) loads the image in the RGB format

    for your case you will have to use CV_LOAD_IMAGE_GRAYSCALE as the second argument

    In the next step where you are using: image.at<unsigned>(0,1); which does not correspond to anything. you use <unsigned> but the compiler says “UNSIGNED? UNSIGNED what???”

    I believe a better way to do this is to use correct labels like CV_LOAD_IMAGE_COLOR or CV_LOAD_IMAGE_GRAYSCALE. In the example below, I am reading the image into one channel (CV_LOAD_IMAGE_GRAYSCALE), which automatically converts it to grayscale.

    #include <cv.h>
    #include <highgui.h>
    
    #include <iostream>
    
    using namespace std;
    using namespace cv;
    
    int main()
    {
        Mat gImg = imread("img.png", CV_LOAD_IMAGE_GRAYSCALE);
    
        uchar val;
        val = gImg.at<uchar>(0,0);
    
        cout << (int)val << endl;
    
        imshow("showImg",gImg);
        cvWaitKey(0);
    
        return 1;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here are two example queries: SELECT NOW(), NOW() + INTERVAL 1 HOUR + INTERVAL
Here is the code in a function I'm trying to revise. This example works
Here is my problem : I have a post controller with the action create.
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();
Here is an example: I write html code inside of textarea, then I swap
Here my problem: @Assert\Regex( * pattern=/^[A-Za-z0-9][A-Za-z0-9\]*$/, * groups={creation, creation_logged} * ) I'm using the
Here's an example query: DECLARE @table table (loc varchar(10)) INSERT INTO @table VALUES ('134a'),
Here is an example: I have the generic type called Account. I wish to
Here is the problem that I am trying to solve. I have two folders
Here's what I'm doing. I want to upload multipart file via Ajax to my

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.