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

  • Home
  • SEARCH
  • 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 8259403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:51:21+00:00 2026-06-08T02:51:21+00:00

I am on windows and use opencv 2.4.2 on C++. I read an image

  • 0

I am on windows and use opencv 2.4.2 on C++.
I read an image with imread and put it in a Mat object.
After that, i get a pointer on the raw data using the function ptr of the Mat class.
I would like to know how works imread when the image contains stride. Is there stride in the data of the Mat or only data of pixels ?

Additional information: I need the raw data because I am using a code written with array and I don’t want to change it for the Mat class.

  • 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-08T02:51:22+00:00Added an answer on June 8, 2026 at 2:51 am

    The stride is that each new row of pixels in the cv::Mat doesn’t start after the end of the last row.
    This is because the memory is faster if it starts on a multiple of 4bytes – so it only matters if the number of bytes in a row (number of pixels * number of colours) isn’t a multiple of 4.

    You can check .isContinuous() will return true if there is no stride

    The safest way of accessing an image is to loop over all the rows and use .ptr(row) to get a pointer to the start of the row, then do any processing on that row.

    If you need to mix opencv with other libs you can create a cv::mat that will use your own memory for the data and you can tell opencv that there is no stride on this

    For lots of details see https://docs.opencv.org/2.4/modules/core/doc/basic_structures.html

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

Sidebar

Related Questions

I have seen that Windows system use temporary files to increase the performance of
I am targeting windows machines. I need to get access to the pointer to
I understand that Histograms of Gradients in OpenCV are typically used on image patches
I found that a lot of Java programs in Windows use .bat batch file
What should I use to perform screen capture on Windows for subsequent image processing?
I have a python program that processes image frames with Python 2.7, PIL, OpenCV,
http://www.barbato.us/2011/03/18/using-opencv2-within-qtcreator-in-windows-2/ I was following this post above on how to use opencv with Qtcreator.
I cant get imread to work, its same problem as this guy: OpenCV imwrite
I use Windows 7, so my progress bars all have that green look. I'd
I have designed a small application in Python under Windows, that uses opencv. I

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.