04-15-2009 02:06 PM
Hi,
I have a 2D array of data and I need to replace a single line of the data because it is corrupted. I'd like to figure out a way to use interpolation or a weighted average of the surrounding data points to replace the line of data with reasonable values. For example, my array could be:
1 2 3 4 3
2 3 4 5 4
x x x x x
4 5 6 7 6
5 6 7 8 7
where I need to replace the line of x's with computed data.
Thanks for any assistance!
Steve
04-15-2009 02:15 PM
Is the data always corrupted in the same row or can different rows be corrupted?
If different rows can be corrupted how do you know what is corrupted and what is not corrupted?
04-15-2009 02:24 PM
The data is acquired by my DAQ card and occasionally the sensor returns a bad line of data. The arrays can be rather large (500x500) and it will always be a horizontal row of data that is corrupted. After the acquisition is complete the user will view the data using an intensity graph and place the cursor on the line of data that they would like to have replaced. When viewed in the intensity graph the data forms a continuous 2D image (the data isn't random) so that the lines that need to be replaced are readily noticed.
04-15-2009 03:24 PM
You can easily replace a row in a 2-D array using the Replace Subset Function.
But the tricky parts of your problem are:
1. How to identify which rows need to be replaced. Even though you say it is obvious on display which are the corrupted rows, how do you want the user to be able to tell the program which rows to replace. You would probably need to use some property nodes of the cursor to identify its position and correlate to a row of data along with a button the user can click to say, "Execute the substitution on the marked row."
2. What kind of algorithm do you want to use to create the new row of data to substitue in.
04-15-2009 04:16 PM
Thanks for the reply.
I've coded up everything for the user to use the cursor to select the line of data, and can use the replace array subset to put in the new data. The problem I'm having is finding an algorithm to create the new row of data. I was considering looking at each column of data so that a single point in each column would need to be replaced, but then realized that all of the other adjoining data points could also contribute to computing the bad data point, which would involve looking at the data in 2D.
Steve
04-15-2009 04:44 PM
Do you have an image or a set of data where the good points and bad points are obvious? If you are looking at one row of data so that each column in that row needs replacement. My first thought would be for a given element in row r, col c, you average row r-1, col c with row r+1, col c. The adjacent bad elements in row r and either col c-1 or c+1 don't come into play.
04-16-2009 08:32 AM
04-16-2009 08:53 AM
I don't know. That is something you are going to have to play with until you figure out something you like.
There are a couple more issues you may have to contend with that show up in your left image. If a bad row is at the edge of the image (like at the bottom as shown), you have no data on the other side to average the row above with. So you might just have to duplicate the row above.
Second, it actually looks like you may have several bad rows next to each other at the bottom of that image. In that case, you wouldn't want to average a good row above with a bad row below, You might have to define a region of bad rows at a time so that the first good row above and bad row below can be average and placed where all the bad rows are.