graphing is opt in now.
This commit is contained in:
parent
25251cd572
commit
8ce167ff0d
|
@ -64,13 +64,14 @@ int main( int argc, char **argv ) {
|
||||||
char *colorChannel = (char *) malloc(sizeof(char)* 32);
|
char *colorChannel = (char *) malloc(sizeof(char)* 32);
|
||||||
char *inputfile = (char *)malloc(sizeof(char) * 32);
|
char *inputfile = (char *)malloc(sizeof(char) * 32);
|
||||||
unsigned *seed = NULL;
|
unsigned *seed = NULL;
|
||||||
unsigned k, xclude = 0;
|
unsigned k, include = 0;
|
||||||
unsigned windowSize = 5;
|
unsigned windowSize = 5;
|
||||||
unsigned samplesCount = 512;
|
unsigned samplesCount = 512;
|
||||||
char *stdcolor = "green", xBuffer[512];
|
char *stdcolor = "green", xBuffer[512];
|
||||||
colorChannel = stdcolor;
|
colorChannel = stdcolor;
|
||||||
unsigned int uint_buffer[1], windowBuffer[1];
|
unsigned int uint_buffer[1], windowBuffer[1];
|
||||||
double learnrate = 0.4;
|
double learnrate = 0.4;
|
||||||
|
char *istrue = "true";
|
||||||
|
|
||||||
|
|
||||||
while( (argc > 1) && (argv[1][0] == '-') ) { // Parses parameters from stdin
|
while( (argc > 1) && (argv[1][0] == '-') ) { // Parses parameters from stdin
|
||||||
|
@ -111,9 +112,14 @@ int main( int argc, char **argv ) {
|
||||||
++argv;
|
++argv;
|
||||||
--argc;
|
--argc;
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'g':
|
||||||
sscanf(&argv[1][3], "%s", xBuffer);
|
sscanf(&argv[1][3], "%s", xBuffer);
|
||||||
xclude = 1;
|
if ( strstr(xBuffer, istrue) ) {
|
||||||
|
include = 1;
|
||||||
|
} else {
|
||||||
|
printf( "Wrong Argruments: %s\n", argv[1]);
|
||||||
|
usage(argv);
|
||||||
|
}
|
||||||
++argv;
|
++argv;
|
||||||
--argc;
|
--argc;
|
||||||
break;
|
break;
|
||||||
|
@ -169,7 +175,7 @@ int main( int argc, char **argv ) {
|
||||||
directPredecessor ( mlData, points);
|
directPredecessor ( mlData, points);
|
||||||
differentialPredecessor( mlData, points );
|
differentialPredecessor( mlData, points );
|
||||||
|
|
||||||
if ( xclude == 0 ) {
|
if ( include == 1 ) {
|
||||||
mkSvgGraph(points); // Graph building
|
mkSvgGraph(points); // Graph building
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -480,8 +486,8 @@ char * fileSuffix ( int id ) {
|
||||||
"_localMean.txt",
|
"_localMean.txt",
|
||||||
"_testvalues.txt",
|
"_testvalues.txt",
|
||||||
"_differential_predecessor.txt",
|
"_differential_predecessor.txt",
|
||||||
"_weights_used_local_mean",
|
"_weights_used_local_mean.txt",
|
||||||
"_weights_used_diff_pred",
|
"_weights_used_diff_pred.txt",
|
||||||
};
|
};
|
||||||
return suffix[id];
|
return suffix[id];
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,12 @@ There are a bunch of options you can predefine but do not have to. The only para
|
||||||
|
|
||||||
| Parameter | Description | StdVal |
|
| Parameter | Description | StdVal |
|
||||||
|:----------|:-----------------------------:|:-------|
|
|:----------|:-----------------------------:|:-------|
|
||||||
| -i | The inputfile, has to be PPM | none |
|
| -i | The inputfile, has to be PPM. | none |
|
||||||
| -n | Amount of input data used | 500 |
|
| -n | Amount of input data used. | 500 |
|
||||||
| -w | Size of M (window) | 5 |
|
| -w | Size of M (window). | 5 |
|
||||||
| -c | Choose RGB color channel, green has least noise. | green |
|
| -c | Choose RGB color channel, green has least noise. | green |
|
||||||
| -l | Learnrate of machine learning | 0.4 |
|
| -l | Learnrate of machine learning.| 0.4 |
|
||||||
| -x | Exclude graph building. Logfiles only, choose for insane amount of input data. 10Mio. Pixels tested so far.| none|
|
| -g true | include graph building. Choose for amount of input data lower than 1200.| none|
|
||||||
| -s | Seed randomizing weights. Choose for repoducability. | time(NULL)|
|
| -s | Seed randomizing weights. Choose for repoducability. | time(NULL)|
|
||||||
|
|
||||||
This code is ANSI compatible no POSIX, C99, C11 or GNU libs, because it had to be VS compatible . There are way easier methods like getline() or getopt(), I know ...
|
This code is ANSI compatible no POSIX, C99, C11 or GNU libs, because it had to be VS compatible . There are way easier methods like getline() or getopt(), I know ...
|
||||||
|
|
|
@ -64,13 +64,14 @@ int main(int argc, char **argv) {
|
||||||
char *colorChannel = (char *) malloc(sizeof(char)* 32);
|
char *colorChannel = (char *) malloc(sizeof(char)* 32);
|
||||||
char *inputfile = (char *)malloc(sizeof(char) * 32);
|
char *inputfile = (char *)malloc(sizeof(char) * 32);
|
||||||
unsigned *seed = NULL;
|
unsigned *seed = NULL;
|
||||||
unsigned k, xclude = 0;
|
unsigned k, include = 0;
|
||||||
unsigned windowSize = 5;
|
unsigned windowSize = 5;
|
||||||
unsigned samplesCount = 512;
|
unsigned samplesCount = 512;
|
||||||
char *stdcolor = "green", xBuffer[512];
|
char *stdcolor = "green", xBuffer[512];
|
||||||
colorChannel = stdcolor;
|
colorChannel = stdcolor;
|
||||||
unsigned int uint_buffer[1], windowBuffer[1];
|
unsigned int uint_buffer[1], windowBuffer[1];
|
||||||
double learnrate = 0.4;
|
double learnrate = 0.4;
|
||||||
|
char *istrue = "true";
|
||||||
|
|
||||||
|
|
||||||
while( (argc > 1) && (argv[1][0] == '-') ) { // Parses parameters from stdin
|
while( (argc > 1) && (argv[1][0] == '-') ) { // Parses parameters from stdin
|
||||||
|
@ -111,9 +112,14 @@ int main(int argc, char **argv) {
|
||||||
++argv;
|
++argv;
|
||||||
--argc;
|
--argc;
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'g':
|
||||||
sscanf(&argv[1][3], "%s", xBuffer);
|
sscanf(&argv[1][3], "%s", xBuffer);
|
||||||
xclude = 1;
|
if ( strstr(xBuffer, istrue) ) {
|
||||||
|
include = 1;
|
||||||
|
} else {
|
||||||
|
printf( "Wrong Argruments: %s\n", argv[1]);
|
||||||
|
usage(argv);
|
||||||
|
}
|
||||||
++argv;
|
++argv;
|
||||||
--argc;
|
--argc;
|
||||||
break;
|
break;
|
||||||
|
@ -144,8 +150,7 @@ int main(int argc, char **argv) {
|
||||||
if ( (seed != NULL) ){
|
if ( (seed != NULL) ){
|
||||||
srand( *seed ); // Seed for random number generating
|
srand( *seed ); // Seed for random number generating
|
||||||
printf("srand is reproducable\n");
|
printf("srand is reproducable\n");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
srand( (unsigned int)time(NULL) );
|
srand( (unsigned int)time(NULL) );
|
||||||
printf("srand depends on time\n"); // Default seed is time(NULL)
|
printf("srand depends on time\n"); // Default seed is time(NULL)
|
||||||
}
|
}
|
||||||
|
@ -170,7 +175,7 @@ int main(int argc, char **argv) {
|
||||||
directPredecessor ( mlData, points);
|
directPredecessor ( mlData, points);
|
||||||
differentialPredecessor( mlData, points );
|
differentialPredecessor( mlData, points );
|
||||||
|
|
||||||
if (xclude == 0) {
|
if ( include == 1 ) {
|
||||||
mkSvgGraph(points); // Graph building
|
mkSvgGraph(points); // Graph building
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -193,7 +198,7 @@ Variant (1/3), substract local mean.
|
||||||
*/
|
*/
|
||||||
void localMean ( mldata_t *mlData, point_t points[] ) {
|
void localMean ( mldata_t *mlData, point_t points[] ) {
|
||||||
double *localWeights = (double *) malloc ( sizeof(double) * mlData->windowSize + 1);
|
double *localWeights = (double *) malloc ( sizeof(double) * mlData->windowSize + 1);
|
||||||
localWeights = mlData->weights; // Copy weights so they can be changed locally
|
localWeights = mlData->weights;
|
||||||
|
|
||||||
char fileName[50];
|
char fileName[50];
|
||||||
double *xError = (double *) malloc ( sizeof(double) * mlData->samplesCount + 1); // Includes e(n)
|
double *xError = (double *) malloc ( sizeof(double) * mlData->samplesCount + 1); // Includes e(n)
|
||||||
|
@ -260,7 +265,7 @@ void localMean(mldata_t *mlData, point_t points[]) {
|
||||||
deviation /= xErrorLength; // Deviation
|
deviation /= xErrorLength; // Deviation
|
||||||
printf("mean:%lf, devitation:%lf\t\tlocal Mean\n", mean, deviation);
|
printf("mean:%lf, devitation:%lf\t\tlocal Mean\n", mean, deviation);
|
||||||
fprintf(fp4, "\nQuadratische Varianz(x_error): %f\nMittelwert:(x_error): %f\n\n", deviation, mean); // Write to logfile
|
fprintf(fp4, "\nQuadratische Varianz(x_error): %f\nMittelwert:(x_error): %f\n\n", deviation, mean); // Write to logfile
|
||||||
//free(localWeights);
|
free(localWeights);
|
||||||
free(xErrorPtr);
|
free(xErrorPtr);
|
||||||
free(xError);
|
free(xError);
|
||||||
|
|
||||||
|
@ -282,6 +287,7 @@ substract direct predecessor
|
||||||
void directPredecessor( mldata_t *mlData, point_t points[]) {
|
void directPredecessor( mldata_t *mlData, point_t points[]) {
|
||||||
double *localWeights = ( double * ) malloc ( sizeof(double) * mlData->windowSize + 1 );
|
double *localWeights = ( double * ) malloc ( sizeof(double) * mlData->windowSize + 1 );
|
||||||
localWeights = mlData->weights;
|
localWeights = mlData->weights;
|
||||||
|
|
||||||
char fileName[512];
|
char fileName[512];
|
||||||
double *xError = (double *) malloc ( sizeof(double) * mlData->samplesCount + 1 );
|
double *xError = (double *) malloc ( sizeof(double) * mlData->samplesCount + 1 );
|
||||||
memset(xError, 0.0, mlData->samplesCount);
|
memset(xError, 0.0, mlData->samplesCount);
|
||||||
|
@ -347,7 +353,7 @@ void directPredecessor(mldata_t *mlData, point_t points[]) {
|
||||||
printf("mean:%lf, devitation:%lf\t\tdirect Predecessor\n", mean, deviation);
|
printf("mean:%lf, devitation:%lf\t\tdirect Predecessor\n", mean, deviation);
|
||||||
fprintf(fp3, "\nQuadratische Varianz(x_error): %f\nMittelwert:(x_error): %f\n\n", deviation, mean);
|
fprintf(fp3, "\nQuadratische Varianz(x_error): %f\nMittelwert:(x_error): %f\n\n", deviation, mean);
|
||||||
fclose(fp3);
|
fclose(fp3);
|
||||||
//free(localWeights);
|
free(localWeights);
|
||||||
free(xErrorPtr);
|
free(xErrorPtr);
|
||||||
free(xError);
|
free(xError);
|
||||||
}
|
}
|
||||||
|
@ -365,9 +371,11 @@ differential predecessor.
|
||||||
void differentialPredecessor ( mldata_t *mlData, point_t points[] ) {
|
void differentialPredecessor ( mldata_t *mlData, point_t points[] ) {
|
||||||
double *localWeights = (double *) malloc ( sizeof(double) * mlData->windowSize + 1 );
|
double *localWeights = (double *) malloc ( sizeof(double) * mlData->windowSize + 1 );
|
||||||
localWeights = mlData->weights;
|
localWeights = mlData->weights;
|
||||||
|
|
||||||
char fileName[512];
|
char fileName[512];
|
||||||
double *xError = (double *) malloc ( sizeof(double) * mlData->samplesCount + 1);
|
double *xError = (double *) malloc ( sizeof(double) * mlData->samplesCount + 1);
|
||||||
memset(xError, 0.0, mlData->samplesCount);
|
memset(xError, 0.0, mlData->samplesCount);
|
||||||
|
|
||||||
unsigned xCount = 0, i;
|
unsigned xCount = 0, i;
|
||||||
double xPredicted = 0.0;
|
double xPredicted = 0.0;
|
||||||
double xActual = 0.0;
|
double xActual = 0.0;
|
||||||
|
@ -430,7 +438,7 @@ void differentialPredecessor(mldata_t *mlData, point_t points[]) {
|
||||||
printf("mean:%lf, devitation:%lf\t\tdifferential Predecessor\n", mean, deviation);
|
printf("mean:%lf, devitation:%lf\t\tdifferential Predecessor\n", mean, deviation);
|
||||||
fprintf(fp6, "\nQuadratische Varianz(x_error): %f\nMittelwert:(x_error): %f\n\n", deviation, mean);
|
fprintf(fp6, "\nQuadratische Varianz(x_error): %f\nMittelwert:(x_error): %f\n\n", deviation, mean);
|
||||||
fclose(fp6);
|
fclose(fp6);
|
||||||
//free(localWeights);
|
free(localWeights);
|
||||||
free(xErrorPtr);
|
free(xErrorPtr);
|
||||||
free(xError);
|
free(xError);
|
||||||
|
|
||||||
|
@ -478,8 +486,8 @@ char * fileSuffix(int id) {
|
||||||
"_localMean.txt",
|
"_localMean.txt",
|
||||||
"_testvalues.txt",
|
"_testvalues.txt",
|
||||||
"_differential_predecessor.txt",
|
"_differential_predecessor.txt",
|
||||||
"_weights_used_local_mean",
|
"_weights_used_local_mean.txt",
|
||||||
"_weights_used_diff_pred",
|
"_weights_used_diff_pred.txt",
|
||||||
};
|
};
|
||||||
return suffix[id];
|
return suffix[id];
|
||||||
}
|
}
|
||||||
|
@ -795,19 +803,16 @@ int ppmColorChannel(FILE* fp, imagePixel_t *image, char *colorChannel, mldata_t
|
||||||
for ( i = 0; i < mlData->samplesCount - 1; i++ ) {
|
for ( i = 0; i < mlData->samplesCount - 1; i++ ) {
|
||||||
fprintf ( fp, "%d\n", image->data[i].green );
|
fprintf ( fp, "%d\n", image->data[i].green );
|
||||||
}
|
}
|
||||||
}
|
} else if ( strcmp(colorChannel, "red") == 0 ){
|
||||||
else if (strcmp(colorChannel, "red") == 0) {
|
|
||||||
for ( i = 0; i < mlData->samplesCount - 1; i++ ) {
|
for ( i = 0; i < mlData->samplesCount - 1; i++ ) {
|
||||||
fprintf ( fp, "%d\n", image->data[i].red );
|
fprintf ( fp, "%d\n", image->data[i].red );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else if ( strcmp(colorChannel, "blue") == 0 ) {
|
||||||
else if (strcmp(colorChannel, "blue") == 0) {
|
|
||||||
for ( i = 0; i < mlData->samplesCount - 1; i++ ) {
|
for ( i = 0; i < mlData->samplesCount - 1; i++ ) {
|
||||||
fprintf ( fp, "%d\n", image->data[i].blue );
|
fprintf ( fp, "%d\n", image->data[i].blue );
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
printf("Colorchannels are red, green and blue. Pick one of them!");
|
printf("Colorchannels are red, green and blue. Pick one of them!");
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,11 @@ There are a bunch of options you can predefine but do not have to. The only para
|
||||||
|
|
||||||
| Parameter | Description | StdVal |
|
| Parameter | Description | StdVal |
|
||||||
|:----------|:-----------------------------:|:-------|
|
|:----------|:-----------------------------:|:-------|
|
||||||
| -i | The inputfile, has to be PPM | none |
|
| -i | The inputfile, has to be PPM. | none |
|
||||||
| -n | Amount of input data used | 500 |
|
| -n | Amount of input data used. | 500 |
|
||||||
| -w | Size of M (window) | 5 |
|
| -w | Size of M (window). | 5 |
|
||||||
| -c | Choose RGB color channel, green has least noise. | green |
|
| -c | Choose RGB color channel, green has least noise. | green |
|
||||||
| -l | Learnrate of machine learning | 0.4 |
|
| -l | Learnrate of machine learning. | 0.4 |
|
||||||
| -x | Exclude graph building. Logfiles only, choose for insane amount of input data. 10Mio. Pixels tested so far.| none|
|
| -g true | include graph building. Choose for amount of input data lower than 1200.| none|
|
||||||
| -s | Seed randomizing weights. Choose for repoducability. | time(NULL)|
|
| -s | Seed randomizing weights. Choose for repoducability. | time(NULL)|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue