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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:56:52+00:00 2026-06-10T14:56:52+00:00

I have image buffer in 24bit RGB format. This buffer is copied to cv::Mat

  • 0

I have image buffer in 24bit RGB format. This buffer is copied to cv::Mat using

cv::Mat mat = cv::Mat(image->height, image->width, CV_8UC3, image->data);

Since this buffer is in RGB format and OpenCV uses BGR format, I’m converting matto BGR with

cv::cvtColor(mat, mat, CV_RGB2BGR);

This works, but when I check original image its channels are inverted as well (and so they become wrong) and I don’t want this to happen.

I’d like to invert mat channels order leaving image-data (my image buffer) untouched. How can I do that?

  • 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-10T14:56:53+00:00Added an answer on June 10, 2026 at 2:56 pm

    I presume (I am not certain) that if you use cv::cvtColor(mat, mat, CV_RGB2BGR);, you actually recreate mat, but you overwrite data with the RGB->BGR converted data. Since you pass data to your “mat” using pointer, if you overwrite the data in mat, you change “image->data” as well.

    Therefore, I do not expect less performance than:

    cv::Mat mat = cv::Mat(image->height, image->width, CV_8UC3, image->data);
    cv::Mat mat2;
    cv::cvtColor(mat, mat2, CV_RGB2BGR);
    //Work with mat 2 now
    

    Rather than overwriting, you write new data. This should bear the same performance cost…
    I do not know what plan to do with your image after colour conversion, but even if the performance was different, it is likely to have an overall minor impact.

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

Sidebar

Related Questions

I have an image width/height/stride and buffer. How do I convert this information to
I have a raw image buffer in the RGB format. I need to draw
I have file Image_RGB565.raw which contains image buffer in RGB565 format. I want this
I have a buffer of UYVY data from a camera and i am using
I have one big buffer image. I want to create another buffer image with
I have a jpeg image in a char[] buffer in memory, all I need
I have written a raw binary image file into a buffer which is an
I have image map that can I move, but this map will be so
I have image on server of dimension 1000x800. I download it using following approaches:
Have some data in a sybase image type column that I want to use

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.