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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:45:52+00:00 2026-05-26T09:45:52+00:00

I am trying to blur an image. I am using a kernel called k[][3]=

  • 0

I am trying to blur an image.

I am using a kernel called k[][3]= { 1, .01, 1, .01, 0, .01, 1, .01, 1};

The code is as follows:

void blur(IplImage *notgray)
{
    IplImage *img = cvCreateImage(cvGetSize(notgray), notgray->depth, 1);
    cvCvtColor(notgray, img, CV_RGB2GRAY);
    int rows=img->height,cols=img->width,row,col,i,j,ki,kj;
    uchar* temp_ptr=0 ;
    float sum,k[][3]= { 1, .01, 1,
                    .01, 0, .01,
                     1, .01, 1};

    for( row = 0; row < rows; ++row) 
    {
            sum=0;
            for ( col = 0; col < cols; ++col) 
            {               
                            temp_ptr  = &((uchar*)(img->imageData + (img->widthStep*row)))[col];
                            for( j=-1,ki=0; j<=1;j++,ki++)
                            {
                                for( i=-1,kj=0; i<=1;i++,kj++)
                                {
                                    int x2=col+i;
                                    int y2=row+j;
                                    if ( x2>=0 && x2<img->width && y2>=0 && y2<img->height) 
                                    {
                                        sum=sum+k[ki][kj];
                                    if (sum<0) sum=0; else if (sum>255) sum=255;
                                    temp_ptr[0]  =(uchar) sum;

                                    }
                                }
                            }
            }

    }
}

I know the output really depends on my algorithm, but looking at the code and output i would request some guidance what i should do further to solve my problem.

  • 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-26T09:45:53+00:00Added an answer on May 26, 2026 at 9:45 am

    You set sum = 0; at the wrong place. Since it is only reset at the start of each row, each pixel will be whiter and whiter and…

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

Sidebar

Related Questions

I'm trying to mash in a simple blur on an image I'm rendering in
I'm trying to blur a depth texture by blurring & blending mipmap levels in
I'm currently writing an image editing application using Flex and I'm trying to make
I am trying to do some image processing on the GPU, e.g. median, blur,
I'm trying to prevent blur to happen when select: in autocomplete is called. (select:
i'm trying to blur every image within a DIV, but for no reason, it
I am using OpenCV and trying to apply a Gaussian Blur to an incoming
I'm trying to use Firebug to debug some Javascript that entails blur and focus
Trying to do this sort of thing... WHERE username LIKE '%$str%' ...but using bound
I am trying to draw a drop shadow underneath an image to which I

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.