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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:40:23+00:00 2026-06-06T02:40:23+00:00

I am trying to program a noise reduction algorithm that works with a set

  • 0

I am trying to program a noise reduction algorithm that works with a set of datapoints in a VB.NET DataTable after being helped with my other question. Basically, I want to take two integers, a coordinate value (yCoord for example) and a threshold smoothing value (NoiseThresh), and take the average of the values in the range of (yCoord - NoiseThresh, yCoord + NoiseThresh) and store that number into an array. I’d repeat that process for each column (in this example) and end up with a one-dimensional array of average values. My questions are:

1) Did anything I just say make any sense ;), and
2) Can anyone help me with the code? I’ve got very little experience working with databases.

Thanks!

An example of what I’m trying to do:

//My data (pretend it's a database)
1  4  4  9  2  //yCoord would equal 5
6  3  8  12 3  //yCoord = 4
8  3 -2  2  0  //yCoord = 3
9 17  3  7  5  //yCoord = 2
4  1  0  9  7  //yCoord = 1

//In this example, my yCoord will equal 3 and NoiseThresh = 1

//For the first column
    Array(column1) = //average of the set of numbers centered at yCoord = 3 _
//(in this case 8) and the NoiseThresh=1 number on either side (here 6 & 9)
//For the second column
    Array(column2) = //average of the numbers 3,3,17 for example
    //etc., etc.,

This would be performed on a large data set (typical numbers would be yCoord=500, NoiseThresh = 50, Array length = 1092) so there is no possibility of manually entering the numbers.

I hope this helps clarify my question!

P.S.: yes, I know that // isn’t a VB.NET comment.

  • 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-06T02:40:25+00:00Added an answer on June 6, 2026 at 2:40 am

    I must admit that i’ve yet not understood the range part (NoiseThresh etc.), but this is a start:

    Dim averages = (From col In tbl.Columns.Cast(Of DataColumn)()
                   Select tbl.AsEnumerable().
                          Average(Function(r) r.Field(Of Int32)(col.ColumnName))).
                   ToArray()
    

    It calculates every average of each column in the DataTable and creates a Double() from the result (average can result in decimal places even if used on integers).

    Edit: With your example i’ve now understood the range part. So basically yCord is the row-index(+1) and noiseThreas is the row-range (+/- n rows).

    Then this gives you the correct result(made some code comments):

    Dim yCord = 2 ' the row index(-1 since indices are 0-based) '
    Dim noiseThresh = 1 ' +/- row '
    ' reverse all rows since your sample begins with index=5 and ends with index=1 '
    Dim AVGs As Double() = (
        From colIndex In Enumerable.Range(0, tbl.Columns.Count)
        Select tbl.AsEnumerable().Reverse().
        Where(Function(r, index) index >= yCord - noiseThresh _
                         AndAlso index <= yCord + noiseThresh).
        Average(Function(r) r.Field(Of Int32)(colIndex))).ToArray()
    

    The most important part of this this LINQ query is the Where. It applies your range on the IEnumerable(of DataRow). Then i’m calculating the average of these rows for every column. The last step is materializing the query to a Double().

    Result:

        (0) 7.666666666666667   Double  => (6+8+9)/3
        (1) 7.666666666666667   Double  => (3+3+17)/3
        (2) 3.0                 Double  => (8-2+3)/3
        (3) 7.0                 Double  => (12+2+7)/3
        (4) 2.6666666666666665  Double  => (3+0+5)/3
    

    Edit2:

    One last thing. I assume that to do the same for the other axis I just
    switch x & y and row & column?

    It’s not that simple. But have a look yourself:

    Dim noiseThresh = 1 ' +/- column '
    Dim xCord = 2 ' the column index(-1 since indices are 0-based) '
    ' assuming that your x-cords now start with index=0 and ends with tbl.Column.Count-1 '
    Dim AVGs As Double() = (
        From rowIndex In Enumerable.Range(0, tbl.Rows.Count)
        Select tbl.Columns.Cast(Of DataColumn)().
        Where(Function(c, colIndex) colIndex >= xCord - noiseThresh _
                            AndAlso colIndex <= xCord + noiseThresh).
        Average(Function(c) tbl.Rows(rowIndex).Field(Of Int32)(c.Ordinal))).ToArray()
    

    Result:

        (0) 5.666666666666667   Double  => (4+4+9)/3
        (1) 7.666666666666667   Double  => (3+8+12)/3
        (2) 1.0                 Double  => (3-2+2)/3
        (3) 9.0                 Double  => (17+3+7)/3
        (4) 3.3333333333333335  Double  => (1+0+9)/3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to program a simple Android app that will stream an internet
I am trying to program the quicksort algorithm from Cormen Algorithm Textbook. Below is
I am trying to program a email piping php script that would take an
I'm trying to get the program to give me a beeping noise. I'm on
I'm trying to program a quicksort-ish algorithm using the Dutch national flag algorithm .
I am trying to program according to Behavior Driven Development, which states that no
I'm trying the program below to divide complex numbers, it works for complex numbers
I was trying to program the algorithm for the cdf for the multivariate t-distribution
I'm trying to program a simple search in google via C# that would run
I am trying with program code from http://liboauth.sourceforge.net/tests_2oauthexample_8c-example.html but every time I am getting

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.