diff options
| author | leochanj105 <leochanj@live.unc.edu> | 2021-10-26 13:22:32 -0400 |
|---|---|---|
| committer | leochanj105 <leochanj@live.unc.edu> | 2021-10-26 13:22:32 -0400 |
| commit | 14c854543b1a3cf344a371a5b45595657f95786b (patch) | |
| tree | 70f752880522e5e44669af365754ac0f649dce81 /SD-VBS/benchmarks/multi_ncut/src/c | |
| parent | 5e2ccfae0532ddd89bcc04bf14aad451e9c79785 (diff) | |
add deadlines and costs
Diffstat (limited to 'SD-VBS/benchmarks/multi_ncut/src/c')
| -rw-r--r-- | SD-VBS/benchmarks/multi_ncut/src/c/.computeMultiW.c.swp | bin | 12288 -> 0 bytes | |||
| -rw-r--r-- | SD-VBS/benchmarks/multi_ncut/src/c/script_multi_ncut.c | 89 | ||||
| -rw-r--r-- | SD-VBS/benchmarks/multi_ncut/src/c/segment-graph.c | 95 | ||||
| -rw-r--r-- | SD-VBS/benchmarks/multi_ncut/src/c/segment-image.c | 142 | ||||
| -rw-r--r-- | SD-VBS/benchmarks/multi_ncut/src/c/segment.h | 46 |
5 files changed, 0 insertions, 372 deletions
diff --git a/SD-VBS/benchmarks/multi_ncut/src/c/.computeMultiW.c.swp b/SD-VBS/benchmarks/multi_ncut/src/c/.computeMultiW.c.swp deleted file mode 100644 index a3b35c6..0000000 --- a/SD-VBS/benchmarks/multi_ncut/src/c/.computeMultiW.c.swp +++ /dev/null | |||
| Binary files differ | |||
diff --git a/SD-VBS/benchmarks/multi_ncut/src/c/script_multi_ncut.c b/SD-VBS/benchmarks/multi_ncut/src/c/script_multi_ncut.c deleted file mode 100644 index b836824..0000000 --- a/SD-VBS/benchmarks/multi_ncut/src/c/script_multi_ncut.c +++ /dev/null | |||
| @@ -1,89 +0,0 @@ | |||
| 1 | /******************************** | ||
| 2 | Author: Sravanthi Kota Venkata | ||
| 3 | ********************************/ | ||
| 4 | |||
| 5 | #include <stdio.h> | ||
| 6 | #include <stdlib.h> | ||
| 7 | #include "segment.h" | ||
| 8 | #include "extra.h" | ||
| 9 | #define MAX_EDGE 500000 | ||
| 10 | int main(int argc, char* argv[]) | ||
| 11 | { | ||
| 12 | SET_UP | ||
| 13 | float sigma = 0.6; | ||
| 14 | float k = 4; | ||
| 15 | int min_size = 10; | ||
| 16 | char im1[256]; | ||
| 17 | int num_ccs[1] = {0}; | ||
| 18 | I2D *out; | ||
| 19 | I2D* im; | ||
| 20 | I2D* seg; | ||
| 21 | I2D* kernel; | ||
| 22 | I2D* ind; | ||
| 23 | I2D* output; | ||
| 24 | int ret; | ||
| 25 | int *segments; | ||
| 26 | edge* edges; | ||
| 27 | universe* u; | ||
| 28 | |||
| 29 | F2D *imageOut, *tempOut; | ||
| 30 | F2D *edgeWeights, *in; | ||
| 31 | scanf("%s", im1); | ||
| 32 | im = readImage(im1); | ||
| 33 | |||
| 34 | |||
| 35 | int height, width, num_edges, num_vertices; | ||
| 36 | height = im->height; | ||
| 37 | width = im->width; | ||
| 38 | num_edges = MAX_EDGE; | ||
| 39 | num_vertices = width * height; | ||
| 40 | segments = (int *) malloc(height*width*sizeof(int)); | ||
| 41 | edges = (edge*)malloc(sizeof(edge)*width*height*4); | ||
| 42 | imageOut = fSetArray(height, width, 0); | ||
| 43 | tempOut = fSetArray(height, width, 0); | ||
| 44 | kernel = iMallocHandle(1,5); | ||
| 45 | edgeWeights = fMallocHandle(1, num_edges); | ||
| 46 | in = fDeepCopy(edgeWeights); | ||
| 47 | ind = fMallocHandle(1, num_edges); | ||
| 48 | u = (universe*)malloc(sizeof(universe)); | ||
| 49 | u->elts = (uni_elt*)malloc(sizeof(uni_elt)*num_vertices); | ||
| 50 | output = iMallocHandle(height, width); | ||
| 51 | |||
| 52 | for_each_job{ | ||
| 53 | seg = segment_image(im, sigma, k, min_size, num_ccs, segments, edges, imageOut, tempOut, kernel, edgeWeights, in, ind, u, output); | ||
| 54 | out = seg; | ||
| 55 | } | ||
| 56 | |||
| 57 | #ifdef CHECK | ||
| 58 | /** Self checking - use expected.txt from data directory **/ | ||
| 59 | { | ||
| 60 | int ret=0; | ||
| 61 | float tol = 0; | ||
| 62 | |||
| 63 | #ifdef GENERATE_OUTPUT | ||
| 64 | writeMatrix(out, argv[1]); | ||
| 65 | #endif | ||
| 66 | |||
| 67 | ret = selfCheck(out, "./expected_C.txt", tol); | ||
| 68 | if(ret < 0) | ||
| 69 | printf("Error in Multi N Cut\n"); | ||
| 70 | } | ||
| 71 | #endif | ||
| 72 | |||
| 73 | iFreeHandle(im); | ||
| 74 | free(edges); | ||
| 75 | free(segments); | ||
| 76 | free(tempOut); | ||
| 77 | free(imageOut); | ||
| 78 | iFreeHandle(kernel); | ||
| 79 | free(edgeWeights); | ||
| 80 | free(in); | ||
| 81 | free(ind); | ||
| 82 | free(output); | ||
| 83 | free(u->elts); | ||
| 84 | free(u); | ||
| 85 | WRITE_TO_FILE | ||
| 86 | return 0; | ||
| 87 | } | ||
| 88 | |||
| 89 | |||
diff --git a/SD-VBS/benchmarks/multi_ncut/src/c/segment-graph.c b/SD-VBS/benchmarks/multi_ncut/src/c/segment-graph.c deleted file mode 100644 index 13b219b..0000000 --- a/SD-VBS/benchmarks/multi_ncut/src/c/segment-graph.c +++ /dev/null | |||
| @@ -1,95 +0,0 @@ | |||
| 1 | /******************************** | ||
| 2 | Author: Sravanthi Kota Venkata | ||
| 3 | ********************************/ | ||
| 4 | |||
| 5 | #include <stdio.h> | ||
| 6 | #include <stdlib.h> | ||
| 7 | #include "segment.h" | ||
| 8 | |||
| 9 | // threshold function | ||
| 10 | #define THRESHOLD(size, c) (c/size) | ||
| 11 | |||
| 12 | int find(universe* u, int x) | ||
| 13 | { | ||
| 14 | int y=x; | ||
| 15 | while (y != u->elts[y].p) | ||
| 16 | y = u->elts[y].p; | ||
| 17 | u->elts[x].p = y; | ||
| 18 | return y; | ||
| 19 | } | ||
| 20 | |||
| 21 | void join(universe* u, int x, int y) | ||
| 22 | { | ||
| 23 | if (u->elts[x].rank > u->elts[y].rank) | ||
| 24 | { | ||
| 25 | u->elts[y].p = x; | ||
| 26 | u->elts[x].size += u->elts[y].size; | ||
| 27 | } | ||
| 28 | else | ||
| 29 | { | ||
| 30 | u->elts[x].p = y; | ||
| 31 | u->elts[y].size += u->elts[x].size; | ||
| 32 | if (u->elts[x].rank == u->elts[y].rank) | ||
| 33 | u->elts[y].rank++; | ||
| 34 | } | ||
| 35 | u->num--; | ||
| 36 | return ; | ||
| 37 | } | ||
| 38 | |||
| 39 | universe *segment_graph(int num_vertices, int num_edges, edge *edges, float c, F2D* edgeWeights, F2D* in, I2D* ind, | ||
| 40 | universe* u) | ||
| 41 | { | ||
| 42 | float threshold[num_vertices]; | ||
| 43 | int i, a, b, j, k; | ||
| 44 | //universe *u; | ||
| 45 | //F2D *edgeWeights; | ||
| 46 | I2D *indices; | ||
| 47 | |||
| 48 | edgeWeights = fResetHandle(edgeWeights,1,num_edges); | ||
| 49 | |||
| 50 | for(i=0; i<num_edges; i++) | ||
| 51 | asubsref(edgeWeights,i) = edges[i].w; | ||
| 52 | |||
| 53 | // sort edges by weight | ||
| 54 | indices = fResortIndices(edgeWeights,1, in, ind); | ||
| 55 | |||
| 56 | // make a disjoint-set forest | ||
| 57 | //u = (universe*)malloc(sizeof(universe)); | ||
| 58 | //u->elts = (uni_elt*)malloc(sizeof(uni_elt)*num_vertices); | ||
| 59 | u->num = num_vertices; | ||
| 60 | for(i=0; i<num_vertices; i++) | ||
| 61 | { | ||
| 62 | u->elts[i].rank = 0; | ||
| 63 | u->elts[i].size = 1; | ||
| 64 | u->elts[i].p = i; | ||
| 65 | } | ||
| 66 | |||
| 67 | // init thresholds | ||
| 68 | for (i = 0; i < num_vertices; i++) | ||
| 69 | arrayref(threshold,i) = THRESHOLD(1,c); | ||
| 70 | |||
| 71 | // for each edge, in non-decreasing weight order... | ||
| 72 | for (i = 0; i < num_edges; i++) | ||
| 73 | { | ||
| 74 | edge *pedge = &edges[ asubsref(indices,i) ]; | ||
| 75 | |||
| 76 | // components conected by this edge | ||
| 77 | a = find(u, pedge->a); | ||
| 78 | b = find(u, pedge->b); | ||
| 79 | if (a != b) | ||
| 80 | { | ||
| 81 | if ((pedge->w <= arrayref(threshold,a)) && (pedge->w <= arrayref(threshold,b))) | ||
| 82 | { | ||
| 83 | join(u, a, b); | ||
| 84 | a = find(u, a); | ||
| 85 | arrayref(threshold,a) = pedge->w + THRESHOLD(u->elts[a].size, c); | ||
| 86 | } | ||
| 87 | } | ||
| 88 | } | ||
| 89 | |||
