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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:00:51+00:00 2026-06-13T23:00:51+00:00

I am a newbie to imaging processing and I found some difficulties in implementing

  • 0

I am a newbie to imaging processing and I found some difficulties in implementing image smoothing.

Basically, I have an image A and I would like to replace everything pixel by its local average. So I define masks M1 = ones(10) and use

 newImage = conv2(A, M1,'same')

It works fine. But in image A, there are meaningless pixels fully due to noise and I don’t want to include them in the averaging. How do I do that, say the meaningful pixels are defined via another mask M2?

I made a simple loop over the image. It works but is way slower than the conv2().

for i = 1:self.row
    for j = 1:self.col
        if self.M2(i,j) % only treat meaningful pixels
            A(i,j) = self.createAvgPhasor(i,j);
        end
    end
end

    function [s_avg]=createAvgPhasor(self,m,n)
        % bound box along x 
        if m > self.rB
            xl = m - self.rB;
        else
            xl = 1;
        end
        if m < self.row_rB
            xu = m + self.rB;
        else
            xu = self.row;
        end
        % bound box along y 
        if n > self.rB
            yl = n - self.rB;
        else
            yl = 1;
        end
        if n < self.col_rB
            yu = n + self.rB;
        else
            yu = self.col;
        end
        M1 = false(self.row,self.col);
        M1(xl:xu,yl:yu) = true;
        msk = M1 & self.M2;
        s_avg = mean(self.Phi(msk));
    end

Thanks very much for your help.

  • 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-13T23:00:52+00:00Added an answer on June 13, 2026 at 11:00 pm

    Excluding the bad points from the convolution is easy. If M2 contains a 1 for pixels that you want to include, and a 0 for those that you don’t, then you just do this:

    newImage = conv2(A.*M2, M1,'same');
    

    This might be sufficient for your purposes, but you have to decide exactly what you mean by ‘averaging”. For example, given your kernal ones(10), at the end you may want to do something like this:

    npts = conv2(ones(size(A)).*M2, M1, 'same')
    newImage = newImage./npts
    

    I.e., divide each pixel by the number of pixels that were actually included in in the convolution for that pixel.

    Actually, the above might also do the right thing even if you weighted different points differently. But it really depends on exactly what you want to do.

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

Sidebar

Related Questions

Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
Hi i'm newbie in C# developer. I would like to save a text-file to
Newbie Objective C/Cocoa question: I have an application with some data entry fields and
Newbie to web-services, so asking few basic questions I have a some data around
I'm an iPhone/iPod-touch newbie, and would like to write an iPhone application utilizing the
newbie question I have a multiselect box that i populate with some ajax and
I am a newbie in Neo4j and I will appreciate some help... I have
newbie rails question coming up. I have a class like this: class Thing <
I have a newbie WPF question. Imagine my user control has a namespace declaration
newbie here, so thanks in advance for help! I have a Wordpress site with

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.