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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:33:59+00:00 2026-05-26T12:33:59+00:00

I am writing a function that takes a OpenCV Mat structure and does some

  • 0

I am writing a function that takes a OpenCV Mat structure and does some processing. The problem is that OpenCV doesn’t seem to have a type independent way for accessing the strucutre so I have to do something like this.

int myfunc(cv::Mat& im, int iRow, int iCol)
{
    int iResult = 0; 
    if (im.type()==CV_16U) iResult = (int)im.at<unsighed short>(iRow, icol);
    else if (im.type()==CV_8U) iResult = (int)im.at<uchar>(iRow, icol);

    return iResult;
}

Is there a clean way to do this?

  • 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-26T12:33:59+00:00Added an answer on May 26, 2026 at 12:33 pm

    It’s because you generally require high performance in image processing and so need different algorithms for 8bit, 16bit or double image types.

    You can do it all with templated types but that’s often just a less readable way of having a switch statement.

    ps if you do care about performance you shouldn’t be using the .at<> operator, get a pointer to the start of the line with .ptr() and then step in units of whatever pixel type you have

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

Sidebar

Related Questions

I have am writing a Python function that takes a timeout value as a
Let's say I'm writing my own function that takes in a CFDataRef object, does
Suppose I'm writing a function that takes a list of integers and returns only
I am writing a function that takes in a output target file and a
I am writing a function that takes a string, string pointer and an int.
I'm writing a wrapper to a function that takes varargin as its inputs. I
I am having some difficulty writing a function that will search through a directory
I'm writing a piece of client-side javascript code that takes a function and finds
I'm writing a function that takes an Enum and casts it to uint .
I'm writing a trimming function that takes a string and finds the first newline

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.