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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:54:49+00:00 2026-06-15T21:54:49+00:00

I created the following function to calculate the point with minimum intensity in an

  • 0

I created the following function to calculate the point with minimum intensity in an image matrix using opencv. However, I’m always getting the point 0,0 as the point with minimum intensity and the values of intensities are also absurd like -2142484923. Can someone help with this?

img is the input image matrix and minloc returns cvPoint with minimum intensity.

int min_Loc(Mat img, Point minloc)
{

    cvtColor(img, img, CV_RGB2GRAY); 
    int x1;
    int y1;
    int x2;
    int y2;

    x1 = 0;
    x2 = img.rows;
    y1 = 0;
    y2 = img.cols;

    int min = std::numeric_limits< int >::max();
    int currentval;
    for (int j=y1; j<y2; j++)
    {

        for (int i=x1; i<x2; i++){
            currentval = img.at<int>(j,i);
            if(currentval < min){
                min = std::min<int>( currentval, min );
                minloc.x = i;
                minloc.y = j;
            }
        }

    }

    return min;


}
  • 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-15T21:54:51+00:00Added an answer on June 15, 2026 at 9:54 pm

    Your function

    int min_Loc(Mat img, Point minloc)
    

    does not return minloc. It returns an integer, and takes a Mat and a Point, both by value. If you want to be able to modify the values of minloc and have that persist after you call min_Loc(), you should use pointers or references as parameters like:

    int min_loc(Mat * img, Point * minloc)
    {
    ...
    minloc->x = i;
    minloc->y = j;
    ...
    return min;
    }
    

    and the call to the function would be like:

    min_loc(&img, &minloc);
    

    this assumes you have somewhere before that call something like:

    Mat img = ...;
    Point minloc = ...;
    

    more info on that: When to pass by reference and when to pass by pointer in C++?

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

Sidebar

Related Questions

I created a lightbox using the following script: <script type=text/javascript> $(document).ready(function(){ $(.BtnAction).click(function(){ var objPopup
I created the following function to simplify a piece of particularly complex code. CREATE
I created the following interface: <?php interface Action { public function execute(\requests\Request $request, array
I am using the following function to create a simple accordion. The problem is
i have the following function i wrote to create an XML file using Xerces
I'm using the following jQuery script to calculate the total width of ul based
I have the following Java object hierarchy: public interface Function { public void calculate(long
I am getting an ambiguity error in OpenCV when I am trying to calculate
I've created the following object: function Calculator() { //some code here, including object variables
I have written the following function to calculate a check digit in R. verhoeffCheck

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.