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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:20:01+00:00 2026-05-28T06:20:01+00:00

I have searched internet and stackoverflow thoroughly, but I haven’t found answer to my

  • 0

I have searched internet and stackoverflow thoroughly, but I haven’t found answer to my question:

How can I get/set (both) RGB value of certain (given by x,y coordinates) pixel in OpenCV? What’s important-I’m writing in C++, the image is stored in cv::Mat variable. I know there is an IplImage() operator, but IplImage is not very comfortable in use-as far as I know it comes from C API.

Yes, I’m aware that there was already this Pixel access in OpenCV 2.2 thread, but it was only about black and white bitmaps.

EDIT:

Thank you very much for all your answers. I see there are many ways to get/set RGB value of pixel. I got one more idea from my close friend-thanks Benny! It’s very simple and effective. I think it’s a matter of taste which one you choose.

Mat image;

(…)

Point3_<uchar>* p = image.ptr<Point3_<uchar> >(y,x);

And then you can read/write RGB values with:

p->x //B
p->y //G
p->z //R
  • 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-05-28T06:20:01+00:00Added an answer on May 28, 2026 at 6:20 am

    Try the following:

    cv::Mat image = ...do some stuff...;
    

    image.at<cv::Vec3b>(y,x); gives you the RGB (it might be ordered as BGR) vector of type cv::Vec3b

    image.at<cv::Vec3b>(y,x)[0] = newval[0];
    image.at<cv::Vec3b>(y,x)[1] = newval[1];
    image.at<cv::Vec3b>(y,x)[2] = newval[2];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched the Internet and stackoverflow.com, but got nothing. Who can give me
I have searched far and wide on the Internet but have not found anything
I have searched the Internet, but I can't find the info I'm looking for.
I have searched the internet looking for a definitive answer to the question of
I don't understand. I have searched all internet forums but found nothing helpful. I
I have searched the internet for an answer to what could be causing EXCEPTION_ACCESS_VIOLATION
I have searched through internet & found that there are no any direct method
I've searched the Internet and have found some good solutions for teeing STDOUT to
I have searched the Internet and I can't seem to find anything related to
I have searched around the internet and stack and have not quite found the

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.