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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:04:03+00:00 2026-06-04T14:04:03+00:00

i try this code to summation the pixels coordinates (x,y) in the image this

  • 0

i try this code to summation the pixels coordinates (x,y) in the image

this is the code

#include<cv.h>
#include<cvaux.h>
#include<stdio.h>
#include<highgui.h>
#include<iostream>
#include<cxtypes.h> // for cvarr 
using namespace std;
// This program to count the pixel value in the gray image
void main()
{
    IplImage* image;
    int w,h;
    char* filename;
    filename="D:\\Recognition\\Image Crop\\7.jpg";
    image=cvLoadImage(filename,0); //for grayscal image
    // Get image attribute
    w=image->width; //image width
    h=image->height; //image height
    cout<<"1. image width "<<w<<"\n2. image height "<<h<<"  \n";
    int Sx,Sy;
    const CvArr* arr;
    CvScalar se; // to store the num
    for(int x=0;x>image->width;x++)
    {
        for(int y=0;image->height;y++)
        {
            se=cvGet2D(image,x,y);
            Sx=se.val[y];
            Sx+=Sx;
        }
        Sy=se.val[x];
        Sy+=Sy;
    }
    cout<<"3. sum x ="<<Sx<<"\n4. sum y ="<<Sy<<" \n";
}

i am trying to calculate the sum of pixel coordinates x and y .

  • 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-04T14:04:05+00:00Added an answer on June 4, 2026 at 2:04 pm

    What’s with these loops?

    for(int x=0;x>image->width;x++)
    {
        for(int y=0;image->height;y++)
    

    Should be:

    for(int x=0;x<image->width;x++)
    {
        for(int y=0;y<image->height;y++)
    

    right?

    Plus also, what’s with this?:

            Sx=se.val[y];
            Sx+=Sx;
    

    You’re resetting Sx every loop iteration and then doubling it, but then throwing that computation away next loop iteration. Similar issues with the Sy.

    I encourage you take a look at your program line by line and really think about what it’s doing before you post questions publically.

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

Sidebar

Related Questions

I want to display pdf file in webview. I try using this code it
i have some question. I try this code and recieve Segmentation fault error: #include
I want to move image to another x,y position. I try this code but
If I have this kind of hierarchy: #include <iostream> using namespace std; template<class T>
I try this code for sent data to MsSql using webservice. when I try
I try this code to change a img image and it work in localhost
I want do custom listview using base adapter in listfragment I try this code:
When I try this code: dict_a = dict_b = dict_c = {} dict_c['hello'] =
When I try this code: if Verbose: print("Building internam Index for %d tile(s) ..."
I want to make this 1332251639632 to this 1332251639 I try this code, but

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.