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 *inputfile = (char *)malloc(sizeof(char) * 32);
|
||||
unsigned *seed = NULL;
|
||||
unsigned k, xclude = 0;
|
||||
unsigned k, include = 0;
|
||||
unsigned windowSize = 5;
|
||||
unsigned samplesCount = 512;
|
||||
char *stdcolor = "green", xBuffer[512];
|
||||
colorChannel = stdcolor;
|
||||
unsigned int uint_buffer[1], windowBuffer[1];
|
||||
double learnrate = 0.4;
|
||||
char *istrue = "true";
|
||||
|
||||
|
||||
while( (argc > 1) && (argv[1][0] == '-') ) { // Parses parameters from stdin
|
||||
|
@ -111,9 +112,14 @@ int main( int argc, char **argv ) {
|
|||
++argv;
|
||||
--argc;
|
||||
break;
|
||||
case 'x':
|
||||
case 'g':
|
||||
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;
|
||||
--argc;
|
||||
break;
|
||||
|
@ -169,7 +175,7 @@ int main( int argc, char **argv ) {
|
|||
directPredecessor ( mlData, points);
|
||||
differentialPredecessor( mlData, points );
|
||||
|
||||
if ( xclude == 0 ) {
|
||||
if ( include == 1 ) {
|
||||
mkSvgGraph(points); // Graph building
|
||||
|
||||
}
|
||||
|
@ -480,8 +486,8 @@ char * fileSuffix ( int id ) {
|
|||
"_localMean.txt",
|
||||
"_testvalues.txt",
|
||||
"_differential_predecessor.txt",
|
||||
"_weights_used_local_mean",
|
||||
"_weights_used_diff_pred",
|
||||
"_weights_used_local_mean.txt",
|
||||
"_weights_used_diff_pred.txt",
|
||||
};
|
||||
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 |
|
||||
|:----------|:-----------------------------:|:-------|
|
||||
| -i | The inputfile, has to be PPM | none |
|
||||
| -n | Amount of input data used | 500 |
|
||||
| -w | Size of M (window) | 5 |
|
||||
| -i | The inputfile, has to be PPM. | none |
|
||||
| -n | Amount of input data used. | 500 |
|
||||
| -w | Size of M (window). | 5 |
|
||||
| -c | Choose RGB color channel, green has least noise. | green |
|
||||
| -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|
|
||||
| -l | Learnrate of machine learning.| 0.4 |
|
||||
| -g true | include graph building. Choose for amount of input data lower than 1200.| none|
|
||||
| -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 ...
|
||||
|
|
|
@ -64,13 +64,14 @@ int main(int argc, char **argv) {
|
|||
char *colorChannel = (char *) malloc(sizeof(char)* 32);
|
||||
char *inputfile = (char *)malloc(sizeof(char) * 32);
|
||||
unsigned *seed = NULL;
|
||||
unsigned k, xclude = 0;
|
||||
unsigned k, include = 0;
|
||||
unsigned windowSize = 5;
|
||||
unsigned samplesCount = 512;
|
||||
char *stdcolor = "green", xBuffer[512];
|
||||
colorChannel = stdcolor;
|
||||
unsigned int uint_buffer[1], windowBuffer[1];
|
||||
double learnrate = 0.4;
|
||||
char *istrue = "true";
|
||||
|
||||
|
||||
while( (argc > 1) && (argv[1][0] == '-') ) { // Parses parameters from stdin
|
||||
|
@ -111,9 +112,14 @@ int main(int argc, char **argv) {
|
|||
++argv;
|
||||
--argc;
|
||||
break;
|
||||
case 'x':
|
||||
case 'g':
|
||||
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;
|
||||
--argc;
|
||||
break;
|
||||
|
@ -144,8 +150,7 @@ int main(int argc, char **argv) {
|
|||
if ( (seed != NULL) ){
|
||||
srand( *seed ); // Seed for random number generating
|
||||
printf("srand is reproducable\n");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
srand( (unsigned int)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);
|
||||
differentialPredecessor( mlData, points );
|
||||
|
||||
if (xclude == 0) {
|
||||
if ( include == 1 ) {
|
||||
mkSvgGraph(points); // Graph building
|
||||
|
||||
}
|
||||
|
@ -193,7 +198,7 @@ Variant (1/3), substract local mean.
|
|||
*/
|
||||
void localMean ( mldata_t *mlData, point_t points[] ) {
|
||||
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];
|
||||
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
|
||||
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
|
||||
//free(localWeights);
|
||||
free(localWeights);
|
||||
free(xErrorPtr);
|
||||
free(xError);
|
||||
|
||||
|
@ -282,6 +287,7 @@ substract direct predecessor
|
|||
void directPredecessor( mldata_t *mlData, point_t points[]) {
|
||||
double *localWeights = ( double * ) malloc ( sizeof(double) * mlData->windowSize + 1 );
|
||||
localWeights = mlData->weights;
|
||||
|
||||
char fileName[512];
|
||||
double *xError = (double *) malloc ( sizeof(double) * mlData->samplesCount + 1 );
|
||||
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);
|
||||
fprintf(fp3, "\nQuadratische Varianz(x_error): %f\nMittelwert:(x_error): %f\n\n", deviation, mean);
|
||||
fclose(fp3);
|
||||
//free(localWeights);
|
||||
free(localWeights);
|
||||
free(xErrorPtr);
|
||||
free(xError);
|
||||
}
|
||||
|
@ -365,9 +371,11 @@ differential predecessor.
|
|||
void differentialPredecessor ( mldata_t *mlData, point_t points[] ) {
|
||||
double *localWeights = (double *) malloc ( sizeof(double) * mlData->windowSize + 1 );
|
||||
localWeights = mlData->weights;
|
||||
|
||||
char fileName[512];
|
||||
double *xError = (double *) malloc ( sizeof(double) * mlData->samplesCount + 1);
|
||||
memset(xError, 0.0, mlData->samplesCount);
|
||||
|
||||
unsigned xCount = 0, i;
|
||||
double xPredicted = 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);
|
||||
fprintf(fp6, "\nQuadratische Varianz(x_error): %f\nMittelwert:(x_error): %f\n\n", deviation, mean);
|
||||
fclose(fp6);
|
||||
//free(localWeights);
|
||||
free(localWeights);
|
||||
free(xErrorPtr);
|
||||
free(xError);
|
||||
|
||||
|
@ -478,8 +486,8 @@ char * fileSuffix(int id) {
|
|||
"_localMean.txt",
|
||||
"_testvalues.txt",
|
||||
"_differential_predecessor.txt",
|
||||
"_weights_used_local_mean",
|
||||
"_weights_used_diff_pred",
|
||||
"_weights_used_local_mean.txt",
|
||||
"_weights_used_diff_pred.txt",
|
||||
};
|
||||
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++ ) {
|
||||
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++ ) {
|
||||
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++ ) {
|
||||
fprintf ( fp, "%d\n", image->data[i].blue );
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
printf("Colorchannels are red, green and blue. Pick one of them!");
|
||||
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 |
|
||||
|:----------|:-----------------------------:|:-------|
|
||||
| -i | The inputfile, has to be PPM | none |
|
||||
| -n | Amount of input data used | 500 |
|
||||
| -w | Size of M (window) | 5 |
|
||||
| -i | The inputfile, has to be PPM. | none |
|
||||
| -n | Amount of input data used. | 500 |
|
||||
| -w | Size of M (window). | 5 |
|
||||
| -c | Choose RGB color channel, green has least noise. | green |
|
||||
| -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|
|
||||
| -l | Learnrate of machine learning. | 0.4 |
|
||||
| -g true | include graph building. Choose for amount of input data lower than 1200.| none|
|
||||
| -s | Seed randomizing weights. Choose for repoducability. | time(NULL)|
|
||||
|
||||
|
|
Loading…
Reference in New Issue