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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:58:40+00:00 2026-06-14T15:58:40+00:00

I have a cv::Mat image; object, which I loaded an image to from a

  • 0

I have a

cv::Mat image;

object, which I loaded an image to from a file, it reads it correctly and all.

Now I have written a function to transform it to grey color.

cv::cvtColor(image, image, CV_RGB2GRAY);

And this error comes up:

OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /build/buildd/opencv-2.3.1/modules/imgproc/src/color.cpp, line 2834
terminate called after throwing an instance of 'cv::Exception'
  what():  /build/buildd/opencv-2.3.1/modules/imgproc/src/color.cpp:2834: error: (-215) scn == 3 || scn == 4 in function cvtColor

what could be the problem?

This is how I read the image (through an imagehandler class which has a member cv::Mat m_image)

imagehandler::imagehandler(const std::string& fileName)
: m_image(imread(fileName, CV_LOAD_IMAGE_COLOR))
{
        if(!m_image.data)
{
    cout << "Failed loading " << fileName << endl;
}

}
  • 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-14T15:58:42+00:00Added an answer on June 14, 2026 at 3:58 pm

    Try using different dst image:

    cv::Mat grayImage;
    cv::cvtColor(image, grayImage, CV_RGB2GRAY);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my application i have a function which receives a cv::Mat object by reference.
in my application I have a Mat file which i'd like to show in
in my programm I have function that takes the image from camera and should
I have image 6750x6450 px and trying to display it with imshow() function from
I have a couple of images in Mat objects all with same dimensions I'd
I have: typedef void (*RespExtractor) (const cv::Mat & image, cv::Mat & resp); virtual void
I have a .mat file that I want to open and see its contents.
i have a file, filedata.mat, containing a 1x1 struct with sub-levels that contain data
I have a file containing the information 0001:Jack:Jeremy:6:38.0 0002:Mat:Steve:1:44.5 0003:Jessy:Rans:10:50.0 0004:Van Red:Jimmy:3:25.75 0005:Peter:John:8:42.25 0006:Mat:Jeff:3:62.0
I have a cv::Mat image, and I am thinking about having a second cv::Mat

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.