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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:05:42+00:00 2026-06-11T11:05:42+00:00

EDIT: My description of a box filter is very wrong (all weights should be

  • 0

EDIT: My description of a box filter is very wrong (all weights should be the same in a box filter), but the answer provided does fix the problem in the picture. Namely the error of not making sure the sum of the weights was equal to 1.

I’m taking a computer graphics class and I am having some issues getting a smoothing box filter to work. For my attempts I’m using a 3×3 mask and convolving it with a source image.
The formula given in my book gives the weights as 1/(2r+1) for discrete and 1/2r for continuous, where r is the radius from the center pixel. So what I’m doing is assigning each value of the 3×3 mask, as

b a b
a 1 a
b a b

where a is 1/3 and b is 1/( ( 2 * sqrt(2) ) +1)

and then convolving it with source image.

The particular library I’m using is CImg which can be found here: http://cimg.sourceforge.net/
and I might as well include my source code and the results.

#include "CImg.h"
#include <cmath>

using namespace cimg_library;
int main() 
{
     CImg<unsigned char> image("zhbackground.bmp"), image2("zhbackground.bmp");
     double a = 1.0/3.0;
     double b = 1.0/((2.0*sqrt(2.0))+1.0);
     CImg<> mask = CImg<>(3,3).fill(b,a,b,a,1,a,b,a,b);
     image2.convolve(mask);
     CImgDisplay main_disp(image,"original"), main_disp2(image2, "second");
     while(1)
     {
        main_disp.wait();main_disp2.wait();
     }
}

original
second

  • 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-11T11:05:43+00:00Added an answer on June 11, 2026 at 11:05 am

    Filter weights should sum to 1.0. Yours do not.

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

Sidebar

Related Questions

May i know how could i edit the style of description of the images
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
EDIT: See my answer below--> I am wanting to have a view that when
Edit : Note that, as Daniel and latkin noted in an answer and a
I have already changed the default text in 'description' box in the enter_bug.cgi page
I have used MVC MVC 2.0 Client Side validation, but it does not work
so I have a box where a user enters some data a description and
I have a dropdown box which only shows active items in the list. But
EDIT: I was an idiot. I simply had an image that was vertically long,
Edit (updated question) I have a simple C program: // it is not important

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.