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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:29:56+00:00 2026-05-26T10:29:56+00:00

Suppose i have an image matrix and i am at a particular pixel [say

  • 0

Suppose i have an image matrix and i am at a particular pixel [say 4] like this:

 0  1  2  
 3 `4` 5  
 6  7  8

I am trying to cycle through all pixels and am attempting to access 0,1,2, 3,5 6,7,8 whose values i am storing in the array called Pixel…. here is my attempt at it using OpenCV, kindly tell me where am i going wrong.

I am using pointer temp_ptr to access the IplImage image.

    uchar* temp_ptr=0 ;
    CvScalar Pixel[3][3];
    int rows=image->height,cols=image->width,row,col;
    for( row = 0; row < rows-2; ++row) 
    {
        for ( col = 0; col < cols-2; ++col) 
            {               
                    temp_ptr  = &((uchar*)(image->imageData + (image->widthStep*row)))[col*3];
                    for (int krow = -1 ; krow <= 1; krow++)
                    {
                        for (int kcol = -1; kcol <= 1; kcol++)
                        {       
                        temp_ptr  = &((uchar*)(image->imageData + (image->widthStep*row+krow)))[(col+kcol)*3];
                            for(int i=0; i < 3; i++)
                            {
                                for(int j=0; j < 3; j++)
                                {
                                    for(int k=0; k < 3; k++)
                                    {
                                        Pixel[i][j].val[k]=temp_ptr[k];
                                    }
                                }
                            }

                        }
                    }
             }
    }

I am not really sure how to load the sorrounding Pixels usingtemp_ptr, please help me out.

  • 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-26T10:29:56+00:00Added an answer on May 26, 2026 at 10:29 am

    Well sir, it sounds like you want to do convolution, and doing it this way when you have OpenCV at your fingertips is a bit like hammering a can opener on your Spaghettios to burst it open by blunt force.

    In fact, what you’re doing is almost exactly the output of cv::blur(src, dst, cv::Size(3,3)) except it also includes the center pixel in the average.

    If you want to exclude the center pixel then you can create a custom kernel – just a matrix with appropriate weights:

    [.125 .125 .125
     .125  0   .125
     .125 .125 .125 ]
    

    and apply this to the image with cv::filter2d(src, dst, -1, kernel).

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

Sidebar

Related Questions

Suppose I have this image: <img src=images/01.jpg border=0 rel=shadow /> Then with jQuery, I
Suppose I have any image(say passport type images where the background will be same
Suppose I have a variable number of static image resources that I would like
I'd like to sum my 4X4 block. Suppose I have an image and will
Suppose I have a few lines out of wikipedia XML that looks like this:
http://en.wikipedia.org/wiki/Rotation_matrix Suppose i have (x,y) 2D pixels for image, now i want to rotate
Hi Suppose I have several image with different width and height, I want all
If I have the original transform matrix of a rectangular UIImageView and this image
Suppose I have a table view, and I want to implement something like this:
Suppose you have something like this HTML FILE: <head></head> <body> <div id=my_personal_div> </div> </body>

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.