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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:51:11+00:00 2026-06-17T04:51:11+00:00

I have been using minMaxLoc to compute the maximum value of the data obtained

  • 0

I have been using minMaxLoc to compute the maximum value of the data obtained by running a laplacian filter over a grayscale image. My simple intention is to roughly estimate the sharpness. I encountered a confusing situation, which I have discussed here.

The max value obtained from the minMaxLoc function was like 1360, 1456,450 etc for a set of images.

    Laplacian(src_gray,dst,ddepth,kernel_size,scale,delta,BORDER_DEFAULT);
    minMaxLoc(dst,&min,&estimate,&minLoc,&maxLoc,noArray());//Estimate is the max value

Now I just tried to compute the average to have a better idea of the spread of the sharpness in the image. Note that DST is the Mat variable holding data from the Laplacian.

    Size s = dst.size();
    rows = s.height;
    cols = s.width;
    total = 0;
    max =  0;
    for(int k=0;k<rows;k++)
    {
      for(int l=0;l<cols;l++)
      {
        total = total + abs(dst.at<int>(k,l));
      }
    }
    average = total/(rows*cols);

There are 2 baffling results I obtained. The average value I obtained, was not only greater than the max value obtained from minMaxLoc, but also was at times negative, when tried over a set of images. sample Average values where 22567, at times -25678.

The occurrence of negative was even more baffling as am using the abs() to get the absolute value of the laplacian results.

To get a proper understanding, I calculated the max value by myself and then the average values :

    Size s = dst.size();
    rows = s.height;
    cols = s.width;
    total = 0;
    max =  0;
    for(int k=0;k<rows;k++)
    {
      for(int l=0;l<cols;l++)
      {
        if(abs(dst.at<int>(k,l))>max)
        {
           max = abs(dst.at<int>(k,l));
        }
        total = total + abs(dst.at<int>(k,l));
       }
    }
    average = total/(rows*cols);

surprisingly, I found the max value to be in 8 digits.

This is why I got confused. What is the max value given from the minMaxLoc function? And why is the abs() in total, not working and why am I getting -ve average values.?

Please forgive me if am missing something in the code, but this is slightly confusing me. Thanks for your help in advance.

  • 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-17T04:51:12+00:00Added an answer on June 17, 2026 at 4:51 am

    I think you should use .at< uchar > instead of int (considering image to be grayscale) otherwise the value will overflow!

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

Sidebar

Related Questions

I have been using Matlab 2011b and contourf/contourfm to plot 2D data on a
I have been using ASIHTTPRequest to fetch the data and i want to cancel
I have been using a mp3 file in my application for over 3 weeks
I have been using the method to import excel data to my WPF application
I have been using TortoiseSVN for some time and I really like it. I
I have been using Stanford POS Tagger to tag parts of speech in a
I have been using play 1.2.5rc4 for development of one app and I have
I have been using an API to do some work. This is how I
I have been using some Javascript to create a text field once an certain
I have been using the storyboard to make an application and currently there are

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.