X

Week 5: Another two features!

Apr 09, 2021

Hello everyone, welcome to the week 5 of my senior project. Last week, I showed
the process of adding the feature of excluding the outlier to plugin and the
summary of the results. This week, I continued to worked on more complex
features of the plugins. Specifically, I added the consideration of brightness
and the outlier to the plugin.

Algorithm

Brightness_PlugThe brightness could be accesses after the number of metrics, the variable
‘nm’, is set to 3 in the code. Then, the last three index in the array stores
the brightness of three tracks. We can access those brightness and correspond
them to the tracks.

After getting the brightness, we treat the values as weights: instead of
adding a track directly, we add the product of brightness value and the track.

Adding toolboxes

Same as last week, we need to create another two toolboxes: brightness and the
brightness outlier. The former one calculates the new track values after
brightness is considered and the later one takes out the outlier.

Code

The below is the code:

else if (chkBrightnessOutlier.Checked)
{
int num = track[0].Count – 2;
double[] stdev = new double[num + 2];
double[] trackSum = new double[track.Count];
// when nm is changed to 3,should I change the index here?
for (int i = 0; i < track.Count; i++)
{
trackSum[i] = 0;
double[] BrightWeight = new double[3];
for (int k = 0; k < 3; k++)
{
BrightWeight[k] = track[k][track[k].Count – (3 – k)];
}
for (int j = 2; j < track[i].Count; j++)
{
trackSum[i] += track[i][j]*BrightWeight[(j+1)%3];
}
trackSum[i] /= num;
}
for (int i = 0; i < track.Count; i++)
{
double max = -1;
int max_index = 0;
double[] BrightWeight = new double[3];
for (int k = 0; k < 3; k++)
{
BrightWeight[k] = track[k][track[k].Count – (3 – k)];
}
for (int j = 2; j < track[i].Count; j++)
{
stdev[j] = Math.Abs(track[i][j]*BrightWeight[(j+1)%3] – trackSum[i]);
if (max < stdev[j])
{
max = stdev[j];
max_index = j;
}
}
double small_weight = 0.5;
double big_weight = (Convert.ToDouble(track.Count) – 0.5) * (track.Count – 1);
double sum = 0;
for (int j = 2; j < track[i].Count; j++)
{
if (j == max_index) sum += small_weight * track[i][j];
else sum += big_weight * track[i][j];
}
sum /= num;
track[i][1] = sum;
}
}
else if (chkBrightness.Checked)
{
int num = track[0].Count – 2;
for (int i = 0; i < track.Count; i++)
{
double sum = 0;
double [] BrightWeight = new double[3];
for (int k=0; k < 3; k++)
{
BrightWeight[k] = track[k][track[k].Count – (3 – k)];
}
for (int j = 2; j < track[i].Count; j++)
sum += track[i][j]*BrightWeight[(j+1)%3];
sum /= num;
track[i][1] = sum;
}

}

Result

The code is working! Below is a screenshot of the image.

Next week

Next week, I am going to have a virtual tour inside the facility in the
library of congress, and I will focus more on what I have learned. Also, I
will be adding features and find better filters for the scanned image.

One Reply to “Week 5: Another two features!”

  1. Eric M. says:

    Glad to see the code is working!

Leave a Reply