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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:33:09+00:00 2026-06-14T23:33:09+00:00

What is the default pixel type of imread create? I test different images, all

  • 0

What is the default pixel type of imread create? I test different images, all of them give me unsigned
char with different channels. Would imread create a pixel type with signed char if I do not ask it
explicitly?

cv::Mat img = cv::imread("lena.jpg", -1); //always give me unsigned char

I checked the document of cv::imread, but it said nothing about the default pixel of imread create.

The link of the document
http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#Mat imread(const string& filename, int flags)

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

    Most .jpg images are 8 bit images. Therfore their default data-type is unsigned char or char.

    Some images like .png or .tif also support 16 bit pixel value, so their data type is unsigned short. But it is not necessary as they may be 8 bit.

    To load the image as-is in OpenCV, use imread like this:

    cv::Mat img = cv::imread(imagePath, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH);
    

    There are different combinations of these flags:

    Load as 8 bit (whatever the original depth is):

    CV_LOAD_IMAGE_COLOR

    Load with original depth:

    CV_LOAD_IMAGE_COLOR | CV_LOAD_IMAGE_ANYDEPTH

    Load as grayscale (no matter how many channels the image has):

    CV_LOAD_IMAGE_GRAYSCALE

    Load as grayscale with original depth:

    CV_LOAD_IMAGE_GRAYSCALE| CV_LOAD_IMAGE_ANYDEPTH

    In your case, lena.jpg is 8 bit image, so you are getting unsigned char data type.

    Update:

    For newer versions of OpenCV, use the flags defined by enum in the C++ interface. Just replace CV_LOAD_IMAGE_* with cv::IMREAD_*.

    e.g. CV_LOAD_IMAGE_GRAYSCALE becomes cv::IMREAD_GRAYSCALE.

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

Sidebar

Related Questions

I've a full set of images at the various different pixel densities, and I
The default strongly-typed Edit page in ASP.NET MVC 3 generally exposes all fields for
I'd like to scale some pixel-art images up in-browser. Because they're pixel art it
Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type help, copyright,
I want resize browser window to 1000x700 pixel by default on load of html
In Delphi, all the TEdit and TComboBox controls are 21 pixels high by default.
I understand that WPF coordinates are different from real screen coodinates (pixel coordinates) if
To make lists horizontal and hide default bullets, is it necessary to give {display:inline}
What are the default font pixel sizes for the heading (h1-h6) tags?
I'm using the Default.png method to create a splashscreen. I'm using the same file

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.