Compare commits

...

13 Commits

Author SHA1 Message Date
gurkenhabicht d09c4d9d68 using gitea now 2023-08-01 23:32:22 +02:00
gurkenhabicht 61f02f3b1d
Update README.md 2018-07-25 10:56:01 +02:00
gurkenhabicht b665ed1c84
Delete LICENSE 2018-07-17 17:30:33 +02:00
gurkenhabicht ea8d27648a
Update README.md 2018-07-06 12:34:47 +02:00
gurkenhabicht 9f9ad7e0c7
Update README.md 2018-07-06 12:32:16 +02:00
gurkenhabicht 16d0b288b5
Create LICENSE 2018-07-06 12:28:58 +02:00
Luke 1a2b7a95f6
Update Messprotokoll.md 2018-06-14 20:01:40 +02:00
kbecke23 3b124f5727 updated cpp exe 2018-06-14 15:36:04 +02:00
gurkenhabicht 2f06ec67b7 moved xError to heap.; 2018-06-14 15:12:32 +02:00
gurkenhabicht dd325b47be Merge branch 'master' of https://github.com/FBRDNLMS/NLMSvariants 2018-06-14 15:06:27 +02:00
Luke 9e360760ff
Update Messprotokoll.md
update, correct and expand our measurement results
2018-06-14 12:23:02 +02:00
kbecke23 3ebbc471a3 Merge branch 'master' of https://github.com/FBRDNLMS/NLMSvariants 2018-06-14 09:31:09 +02:00
kbecke23 b42c915afc updated .exe 2018-06-14 09:28:50 +02:00
12 changed files with 44726 additions and 43 deletions

View File

@ -2,13 +2,13 @@
# Objective
The goal of our task was to implement three kinds of a least mean square filter.
The goal of our task was to implement four variants of a least mean square filter.
According to the given task we created implementations in ANSI C, C++ and C#.
Input of these filters are image files, namely BMP, GIF, EXIF, JPG, PNG and TIFF in C#.
Input given to these filters are image files, namely BMP, GIF, EXIF, JPG, PNG and TIFF in C#.
PPM in ANSI C and C++ _only_.
In each of these implementations there are log files and graphs as an output.
More information can be found inside the according folders.
More information can be found in according folders.
# Structure
```

Binary file not shown.

BIN
bin/a.out Executable file

Binary file not shown.

90
bin/input.c Normal file
View File

@ -0,0 +1,90 @@
#include <stdio.h>
#include <stdio.h>
#define RGB_COLOR 255
typdef struct{
unsigned char red, green, blue;
} colorChannel_t;
typdef struct{
int x,y;
colorChannel *data;
} imagePixel_t;
static imagePixel_t *readPPM( const char *fileName ) {
char buffer[16];
imagePixel_t *image;
int c, rgbColor;
FILE *fp = fopen(fileName, "r");
if( !fp ) {
exit(EXIT_FAILURE);
}
if( !fgets(buffer, sizeof(buffer), fp);
perror(filename);
exit(EXIT_FAILURE);
}
if( buffer[0] != 'P' || buffer[1] != '6' ) {
fprintf(stderr, "Invalid file format \n");
exit(EXIT_FAILURE);
}
image = (imagePixel_t *) malloc(sizeof(imagePixel_t));
if( !image ) {
fprintf(stderr, "malloc() failed");
}
c = getc(fp);
while( c == '#' ) {
while( getc(fp) !='\n' ) {
c = getc(fp);
}
ungetc(c, fp);
if( scanf(fp, "%d %d", $image->, &img->) != 2 ) {
fprintf(stderr, "Invalid image size in %s\n)", filename);
exit(EXIT_FAILURE);
}
if( rgbColor != RGB_COLOR ) {
fprintf(stderr,"Invalid image color range in %s\n", filename);
exit(EXIT_FAILURE);
}
while(fgetc(fp) != '\n') {
image.data = (imagePixel_t *) malloc(image.x * image.y * sizeof(imagePixel_t));
if ( !img ) {
fprintf(stderr, "malloc() failed");
exit(EXIT_FAILURE);
}
if ( fread( image.data, 3 * image.x, image.y, fp ) != img.y ) {
fprintf(stderr, "Loading image failed");
exit(EXIT_FAILURE);
}
}
fclose( fp );
return image;
}
int *mkPpmTestArray (int* testarray, imagePixel_t *image ) {
int i;
int output [image.x * image.y]
if ( !image ) {
for ( i = 0; i < image.x * image.y>; i++ ) {
// image.data[i].red = RGB_COLOR - image[i].red;
// image.data[i].green = RGB_COLOR - image.data[i].green;
// image.data[i].blue = RGB_COLOR - image.data[i].blue;
output[i] = image.data[i].red;
}
}
}
void main ( void ) {
char *fN = "beaches.ppm"
int testarray [1024];
imagePixel_t result;
result = readPPM(fN);
mkPpmTestArray(testarray, result);
for (int i = 0; i < 1023; i++ ) {
printf("%d\n", testArray[i];
}
}

View File

@ -1,7 +1,8 @@
# 1. CPP-NLMS-Testreihe
## 1.1 Veränderung der Lernrate
#### Paramter:
- Input: 500.000 Pixel (-n 500000)
- WindowSize: 5 (Standard Value)
- WindowSize: 5 (Standart Value)
- Lernrate von 0.1 bis 1.0 (increased by 0.1)
- -i cathedral.ppm
- random seed generator : 3 (-s 3)
@ -9,51 +10,92 @@
### 1. Local Mean
Lernrate | meanerror | devitation
--- | --- | ---
0.1 | 0.017622| 264.808714
0.2 | 0.035715| 563.756509
0.3 | 0.054145| 1058.390726
0.4 | 0.072960| 1749.137624
0.5 | 0.092207| 2636.592222
0.6 | 0.111931| 3721.514220
0.7 | 0.132180| 5004.829359
0.8 | 0.153002| 6487.641093
0.9 | 0.174440| 8171.260237
1.0 | 0.196529| 10057.264574
Lernrate | meanerror | variance
--- | --- | ---
0.1 | 0.020861| 373.760784
0.2 | -0.015231| 1261.386282
0.3 | -0.054507| 2574.244199
0.4 | -0.088173| 4229.104809
0.5 | -0.116079 | 6169.762185
0.6 | -0.139313 | 8360.777760
0.7 | -0.158889 | 10783.351638
0.8 | -0.175600 | 13432.957565
0.9 | -0.190101 | 16318.529330
1.0 | -0.202958 | 19463.062580
### 2. direct Predecessor
Lernrate | meanerror | devitation
Lernrate | meanerror | variance
--- | --- | ---
0.1 | 0.034605| 1165.639836
0.2 | 0.061290| 5143.795751
0.3 | 0.081941| 14101.954880
0.4 | 0.098059| 33151.61923
0.5 | 0.111109| 73575.962146
0.6 | 0.123070| 159449.145873
0.7 | 0.138492| 347221.927325
0.8 | 519.742508| 8159987385389.823242
0.9 | -7547134082896249132941312.000000| 3877153348329978955993364733716443880442465820831329026048.000000
1.0 | 3761239144093188417284117395383469067145028584884793393044299775046771047758036992.000000| 2074572983654522674987602010560539857768301297996124872466118751856211301657828168212459204392861396853691477732320683100737172969672730282637731961860360049654132492992512.000000
0.1 | 0.024560 | 608.448633
0.2 | -0.030306 | 2007.513911
0.3 | -0.084634 | 3959.201147
0.4 | -0.126798 | 6328.009325
0.5 | -0.157719 | 9057.241991
0.6 | -0.179736 | 12137.852301
0.7 | -0.194805 | 15592.808948
0.8 | -0.204488 | 19471.279015
0.9 | -0.210085 | 23849.267714
1.0 | -0.212681 | 28835.466521
### 3. differential Predecessor
Lernrate | meanerror | devitation
Lernrate | meanerror | variance
--- | --- | ---
0.1 | 0.002158| 35.172878
0.2 | 0.003306| 33.315664
0.3 | 0.003656| 32.549577
0.4 | 0.003311| 33.097449
0.5 | 0.002340| 35.717416
0.6 | 0.000869| 43.040214
0.7 | -0.000213| 71.249809
0.8 | 0.013732| 1363.663734
0.9 | -0.071016| 4623896.100036
1.0 | -211924.365595| 556770831730198528.000000
0.1 | 0.046246 | 237.604268
0.2 | 0.058362 | 838.182243
0.3 | 0.060553 | 1834.829054
0.4 | 0.060390 | 3227.671286
0.5 | 0.060858 | 5016.829374
0.6 | 0.063120 | 7202.687465
0.7 | 0.067694 | 9785.843689
0.8 | 0.074840 | 12767.049840
0.9 | 0.084710 | 16147.248088
1.0 | 0.097443 | 19927.694764
### 4. NLMS
Lernrate | meanerror | variance
--- | --- | ---
0.1 | -0.865235 | 51.897994
0.2 | -0.916315 | 67.761425
0.3 | -0.950006 | 82.291526
0.4 | -0.975096 | 96.554001
0.5 | -0.995089 | 111.236008
0.6 | -1.011618 | 126.820482
0.7 | -1.025538 | 143.713619
0.8 | -1.037385 | 162.334219
0.9 | -1.047550 | 183.192878
1.0 | -1.056358 | 206.993456
## 1.2 Veränderung der WindowSize
#### Paramter:
- Input: 500.000 Pixel (-n 500000)
- WindowSize: -w {1,3,5, 8, 10, 15, 20, 25, 50, 100}
- Lernrate: -l 0.6
- -i cathedral.ppm
- random seed generator : 3 (-s 3)
>Tabelle beinhaltet jeweils den 'mean error' der jeweiligen Variante
| Windowsize | local Mean | direct Predecessor | differential Predecessor | NLMS |
|---|---|---|---|---|
| 1 | 0.330125 | 0.330131 | 0.330131 | -1.063652 |
| 3 | 0.444605 | 0.412069 | 0.413190 | -1.089547 |
| 5 | -0.139313 | -0.179736 | 0.063120 | -1.011618 |
| 8 | 0.181180 | 0.042986 | 0.221078 | -0.873373 |
| 10 | 0.279242 | 0.188497 | 0.291145 | -0.811906 |
| 15 | 0.215564 | 0.222018 | 0.265400 | -0.696719 |
| 20 | 0.273161 | 0.383155 | 0.194116 | -0.615447 |
| 25 | 0.213731 | 0.276315 | 0.185892 | -0.576340 |
| 50 | 0.467920 | 0.463972 | 0.188099 | -0.479407 |
| 100 | -0.331102 | -0.412149 | -0.018204 | -0.506369 |
___
# 2. CS-NLMS-Testreihe
#### Parameter:
-N:4000 Pixel

View File

@ -202,7 +202,7 @@ void standardNLMS( mldata_t *mlData, point_t points[] ) {
char fileName[512];
const unsigned xErrorLength = mlData->samplesCount;
double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount);
double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount + 1);
unsigned i, xCount = 0;
mkFileName ( fileName, sizeof(fileName), STANDARD_NLMS);
@ -280,7 +280,7 @@ void localMean ( mldata_t *mlData, point_t points[] ) {
char fileName[512];
const unsigned xErrorLength = mlData->samplesCount;
double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount);
double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount + 1);
unsigned i, xCount = 0; // Runtime vars
@ -363,7 +363,7 @@ void directPredecessor( mldata_t *mlData, point_t points[]) {
char fileName[512];
const unsigned xErrorLength = mlData->samplesCount;
double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount);
double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount + 1);
unsigned xCount = 0, i;
double xActual = 0.0;
@ -443,7 +443,7 @@ void differentialPredecessor ( mldata_t *mlData, point_t points[] ) {
memcpy(localWeights, mlData->weights, sizeof(double) * mlData->windowSize + 1);
const unsigned xErrorLength = mlData->samplesCount;
char fileName[512];
double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount);
double *xError = (double *) malloc ( sizeof(double) *mlData->samplesCount + 1);
unsigned xCount = 0, i;
double xPredicted = 0.0;

View File

@ -29,7 +29,7 @@ There are a bunch of options you can predefine but do not have to. The only para
| -w | Size of M (window). | 5 |
| -c | Choose RGB color channel, green has least noise. | green |
| -l | Learnrate of machine learning.| 0.4 |
| -g | include graph building. Choose for amount of input data lower than 1200. If the template is located in another folder use its path otherwise use true. Do not use whitespace in path to folder.| none|
| -g | include graph building. Choose for any amount of input data lower than 1200 pixels. If the template is located in another folder use its __path__, otherwise use __true__. Do not use whitespace in path to folder.| none|
| -s | Seed randomizing weights. Choose for repoducability. | time(NULL)|
This code is ANSI aka C89 compatible. No POSIX, C99, C11 or GNU libs, because it had to be windows compatible . There are way easier methods like getline() for file parsing or getopt() as an args parser, because of compatibility reasons things have been kept simple.

BIN
src/ansi_c_implementation/a.out Executable file

Binary file not shown.

File diff suppressed because one or more lines are too long

BIN
src/ansi_c_implementation/lms Executable file

Binary file not shown.

View File

@ -0,0 +1,14 @@
#include <stdio.h>
void main ( void ) {
unsigned ui_one = 1;
signed i_one = 1;
signed short s_minus_one = -1;
if ( s_minus_one > ui_one ) {
printf("-1 > 1\n");
}
if ( s_minus_one < i_one ) {
printf("-1 < 1\n");
}
}

View File

@ -270,6 +270,7 @@ void standardNLMS(mldata_t *mlData, point_t points[]) {
fprintf(fp01, "\nQuadratische Varianz(x_error): %f\nMittelwert:(x_error): %f\n\n", deviation, mean);
free(localWeights);
free(xError);
}
@ -354,6 +355,7 @@ void localMean(mldata_t *mlData, point_t points[]) {
fclose(fp4);
free(localWeights);
free(xError);
}
/*
@ -435,6 +437,7 @@ void directPredecessor(mldata_t *mlData, point_t points[]) {
fclose(fp3);
free(localWeights);
free(xError);
}
/*
@ -522,6 +525,7 @@ void differentialPredecessor(mldata_t *mlData, point_t points[]) {
fclose(fp6);
free(localWeights);
free(xError);
}
/*