diff options
| author | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-17 19:07:11 -0400 |
|---|---|---|
| committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-17 20:54:41 -0400 |
| commit | 1120161286ee5c855b630bccc9e0b37bb8a3ee65 (patch) | |
| tree | 082a47491403a624a28f8b2bf8e20bbdb3f5e0e7 /dis/Neighborhood/utili.h | |
| parent | 5aad2261f7c012aa16a93c7c5bf6bda0081658fb (diff) | |
Fix DIS coding style by running them all through clang-format
Also fixes a missing header in DISstressmarkRNG.h and the "all"
make target. No functional changes.
Diffstat (limited to 'dis/Neighborhood/utili.h')
| -rw-r--r-- | dis/Neighborhood/utili.h | 435 |
1 files changed, 198 insertions, 237 deletions
diff --git a/dis/Neighborhood/utili.h b/dis/Neighborhood/utili.h index 5b54d9b..b5a7498 100644 --- a/dis/Neighborhood/utili.h +++ b/dis/Neighborhood/utili.h | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Sample code for the DIS Pointer Stressmark | 2 | * Sample code for the DIS Pointer Stressmark |
| 3 | * | 3 | * |
| 4 | * This source code is the completely correct source code based on | 4 | * This source code is the completely correct source code based on |
| 5 | * the example codes provided by Atlantic Aerospace Division, Titan | 5 | * the example codes provided by Atlantic Aerospace Division, Titan |
| 6 | * Systems Corporation, 2000. | 6 | * Systems Corporation, 2000. |
| 7 | * | 7 | * |
| 8 | * If you just compile and generate the executables from this source | 8 | * If you just compile and generate the executables from this source |
| 9 | * code, this code would be enough. However, if you wish to get a complete | 9 | * code, this code would be enough. However, if you wish to get a complete |
| 10 | * understanding of this stressmark, it is strongly suggested that you | 10 | * understanding of this stressmark, it is strongly suggested that you |
| 11 | * read the Benchmark Analysis and Specifications Document Version 1.0 | 11 | * read the Benchmark Analysis and Specifications Document Version 1.0 |
| 12 | * before going on since the detailed comments are given in this documents. | 12 | * before going on since the detailed comments are given in this documents. |
| @@ -22,287 +22,248 @@ | |||
| 22 | 22 | ||
| 23 | #define MIN_PIXEL 0 | 23 | #define MIN_PIXEL 0 |
| 24 | #define MAX_DIMENSION 32768 | 24 | #define MAX_DIMENSION 32768 |
| 25 | #define MIN_SEED -2147483647 | 25 | #define MIN_SEED -2147483647 |
| 26 | #define MAX_SEED -1 | 26 | #define MAX_SEED -1 |
| 27 | #define MAX_NUMBER_LINES 65536 | 27 | #define MAX_NUMBER_LINES 65536 |
| 28 | #define MIN_BIT_DEPTH 7 | 28 | #define MIN_BIT_DEPTH 7 |
| 29 | #define MAX_BIT_DEPTH 15 | 29 | #define MAX_BIT_DEPTH 15 |
| 30 | 30 | ||
| 31 | typedef struct { | 31 | typedef struct { |
| 32 | int column; | 32 | int column; |
| 33 | int row; | 33 | int row; |
| 34 | }Coord; | 34 | } Coord; |
| 35 | 35 | ||
| 36 | /* | 36 | /* |
| 37 | * Neighborhood structure consists of the GLCM descriptors entropy and | 37 | * Neighborhood structure consists of the GLCM descriptors entropy and |
| 38 | * energy for each of 2 distance and 4 angels | 38 | * energy for each of 2 distance and 4 angels |
| 39 | */ | 39 | */ |
| 40 | typedef struct { | 40 | typedef struct { |
| 41 | float entropy; | 41 | float entropy; |
| 42 | float energy; | 42 | float energy; |
| 43 | }Descriptors; | 43 | } Descriptors; |
| 44 | 44 | ||
| 45 | typedef struct { | 45 | typedef struct { |
| 46 | Descriptors deg0; | 46 | Descriptors deg0; |
| 47 | Descriptors deg45; | 47 | Descriptors deg45; |
| 48 | Descriptors deg90; | 48 | Descriptors deg90; |
| 49 | Descriptors deg135; | 49 | Descriptors deg135; |
| 50 | }Angeles; | 50 | } Angeles; |
| 51 | 51 | ||
| 52 | typedef struct { | 52 | typedef struct { |
| 53 | Angeles distShort; | 53 | Angeles distShort; |
| 54 | Angeles distLong; | 54 | Angeles distLong; |
| 55 | }Neighborhood; | 55 | } Neighborhood; |
| 56 | 56 | ||
| 57 | typedef short int Pixel; /* short int;*/ | 57 | typedef short int Pixel; /* short int;*/ |
| 58 | 58 | ||
| 59 | typedef struct { | 59 | typedef struct { |
| 60 | int numColumns; /* number of columns in image */ | 60 | int numColumns; /* number of columns in image */ |
| 61 | int numRows; /* number of rows in image */ | 61 | int numRows; /* number of rows in image */ |
| 62 | Pixel maxImageValue; /* max legal image value */ | 62 | Pixel maxImageValue; /* max legal image value */ |
| 63 | Pixel *data; /* data pointer */ | 63 | Pixel *data; /* data pointer */ |
| 64 | } Image; | 64 | } Image; |
| 65 | 65 | ||
| 66 | // For correct implementation of drawLineSegment | 66 | // For correct implementation of drawLineSegment |
| 67 | #include "initializeImage.c" | 67 | #include "initializeImage.c" |
| 68 | 68 | ||
| 69 | Pixel *createImage (Pixel *image, | 69 | Pixel *createImage(Pixel *image, int dimension, Pixel maxPixel, int numberLines, |
| 70 | int dimension, | 70 | int minThickness, int maxThickness) { |
| 71 | Pixel maxPixel, | 71 | int i; |
| 72 | int numberLines, | 72 | |
| 73 | int minThickness, | 73 | Coord startPoint; |
| 74 | int maxThickness) | 74 | Coord endPoint; |
| 75 | { | 75 | int thickness; |
| 76 | int i; | 76 | int startValue; |
| 77 | 77 | int endValue; | |
| 78 | Coord startPoint; | 78 | Image img; |
| 79 | Coord endPoint; | 79 | img.numColumns = dimension; |
| 80 | int thickness; | 80 | img.numRows = dimension; |
| 81 | int startValue; | 81 | img.maxImageValue = maxPixel; |
| 82 | int endValue; | 82 | img.data = image; |
| 83 | Image img; | 83 | |
| 84 | img.numColumns = dimension; | 84 | for (i = 0; i < dimension * dimension; i++) { |
| 85 | img.numRows = dimension; | 85 | image[i] = 0; |
| 86 | img.maxImageValue = maxPixel; | 86 | } |
| 87 | img.data = image; | ||
| 88 | |||
| 89 | for (i=0; i<dimension*dimension; i++){ | ||
| 90 | image[i] = 0; | ||
| 91 | } | ||
| 92 | 87 | ||
| 93 | for (i=0; i<numberLines; i++){ | 88 | for (i = 0; i < numberLines; i++) { |
| 94 | float temp; | 89 | float temp; |
| 95 | float prev; | 90 | float prev; |
| 96 | 91 | ||
| 97 | temp = randomUInt(0, dimension*dimension - 1); | 92 | temp = randomUInt(0, dimension * dimension - 1); |
| 98 | startPoint.row = (int) temp/dimension; | 93 | startPoint.row = (int)temp / dimension; |
| 99 | startPoint.column = (int) temp % dimension; | 94 | startPoint.column = (int)temp % dimension; |
| 100 | prev = temp; | 95 | prev = temp; |
| 101 | 96 | ||
| 102 | // Make sure that the end is different than the start | 97 | // Make sure that the end is different than the start |
| 103 | while((temp = randomUInt(0, dimension*dimension -1)) == prev); | 98 | while ((temp = randomUInt(0, dimension * dimension - 1)) == prev) |
| 99 | ; | ||
| 104 | 100 | ||
| 105 | endPoint.row = (int) temp/dimension; | 101 | endPoint.row = (int)temp / dimension; |
| 106 | endPoint.column = (int) temp% dimension; | 102 | endPoint.column = (int)temp % dimension; |
| 107 | 103 | ||
| 108 | thickness = randomUInt(minThickness, maxThickness); | 104 | thickness = randomUInt(minThickness, maxThickness); |
| 109 | startValue = randomUInt(MIN_PIXEL, maxPixel); | 105 | startValue = randomUInt(MIN_PIXEL, maxPixel); |
| 110 | endValue = randomUInt(MIN_PIXEL, maxPixel); | 106 | endValue = randomUInt(MIN_PIXEL, maxPixel); |
| 111 | 107 | ||
| 112 | drawLineSegment(&startPoint, &endPoint, | 108 | drawLineSegment(&startPoint, &endPoint, startValue, endValue, thickness, |
| 113 | startValue, endValue, thickness, &img); | 109 | &img); |
| 114 | } | 110 | } |
| 115 | return(image); | 111 | return (image); |
| 116 | } | 112 | } |
| 117 | 113 | ||
| 114 | void calcEntropyEnergy(int *sumHist, int *diffHist, Pixel *image, int numBins, | ||
| 115 | int dx, int dy, float *entropy, float *energy, | ||
| 116 | int dimension, Pixel maxPixel) { | ||
| 117 | int index; | ||
| 118 | int totalNumPixels; | ||
| 119 | int rowIndex; | ||
| 120 | int rowLow, rowHigh; | ||
| 121 | int columnIndex; | ||
| 122 | int columnLow, columnHigh; | ||
| 123 | int columnForPixelAtDistance; | ||
| 124 | int rowForPixelAtDistance; | ||
| 125 | int value0RowOffset; | ||
| 126 | int value1RowOffset; | ||
| 127 | |||
| 128 | *entropy = 0.0; | ||
| 129 | *energy = 0.0; | ||
| 130 | |||
| 131 | for (index = 0; index < numBins; index++) { | ||
| 132 | sumHist[index] = 0; | ||
| 133 | diffHist[index] = 0; | ||
| 134 | } | ||
| 118 | 135 | ||
| 119 | void calcEntropyEnergy( | 136 | if (dy < 0) { |
| 120 | int *sumHist, | 137 | rowLow = -dy; |
| 121 | int *diffHist, | 138 | rowHigh = dimension; |
| 122 | Pixel *image, | 139 | } else { |
| 123 | int numBins, | 140 | rowLow = 0; |
| 124 | int dx, | 141 | |
