diff --git a/data/run_helper.txt b/data/run_helper.txt new file mode 100644 index 0000000..98e4d12 --- /dev/null +++ b/data/run_helper.txt @@ -0,0 +1,46 @@ +Dataset X { + int NUMBER_OF_POINTS = 600; + int DIMENSIONS = 2; + char* POINTS_FILENAME = "data/X.bin"; + + A good h is 1 + For Processing script: + float maxX = 17.124000; + float minX = 3.402000; + float maxY = 14.996000; + float minY = 3.178000; + + 12 iterations +} + +Dataset s1 { + int NUMBER_OF_POINTS = 5000; + int DIMENSIONS = 2; + char* POINTS_FILENAME = "data/s1"; + + A good h is 30000 + For Processing script: + float maxX = 961951; + float minX = 19835; + float maxY = 970756; + float minY = 51121; + + ~28 iterations +} + +Dataset s4 { + int NUMBER_OF_POINTS = 5000; + int DIMENSIONS = 2; + char* POINTS_FILENAME = "data/s4"; + + A good h is 30000-35000 + For Processing script: + float maxX = 932954; + float minX = 89604; + float maxY = 977215; + float minY = 35412; + + 122 iterations with epsilon = 0.0001 and h = 30000 + 110 iterations with epsilon = 0.01 and h = 30000 + 108 iterations with epsilon = 1 and h = 31000 +} \ No newline at end of file diff --git a/data/s1 b/data/s1 new file mode 100644 index 0000000..92894e1 Binary files /dev/null and b/data/s1 differ diff --git a/data/s4 b/data/s4 new file mode 100644 index 0000000..2e8eea8 Binary files /dev/null and b/data/s4 differ diff --git a/output/visualization/visualization.pde b/output/visualization/visualization.pde index 325f21f..d332cf9 100644 --- a/output/visualization/visualization.pde +++ b/output/visualization/visualization.pde @@ -2,20 +2,24 @@ int frame = 1; PShape frameS; void setup() { - size(1280, 720); + size(720, 720); frameRate(12); } -int scale = 40; +int scale = 1; float radius = 2; +float maxX = 17.124000; +float minX = 3.402000; +float maxY = 14.996000; +float minY = 3.178000; void draw() { background(255); stroke(0); - translate(220, 0); //scale(scale); fill(0); + System.out.println("frame = " + frame); String[] lines; lines = loadStrings("../output_" + frame); if (lines == null){ @@ -24,11 +28,14 @@ void draw() { } else { for (int i = 0; i < lines.length; i++) { String[] pieces = split(lines[i], ","); - frameS = createShape(ELLIPSE, Float.parseFloat(pieces[0])*scale,Float.parseFloat(pieces[1])*scale, radius, radius); + float mapedX = map(Float.parseFloat(pieces[0]), minX, maxX, 0, 720); + float mapedY = map(Float.parseFloat(pieces[1]), minY, maxY, 0, 720); + frameS = createShape(ELLIPSE, mapedX*scale, mapedY*scale, radius, radius); shape(frameS, 0, 0); } } frame++; + //Uncomment to save each frame to a jpg file //saveFrame("out-######.jpg"); delay(600); diff --git a/serial.c b/serial.c index 3b8ec33..329a20f 100755 --- a/serial.c +++ b/serial.c @@ -68,5 +68,5 @@ int main(int argc, char **argv){ printf("%s wall clock time = %f\n","Mean Shift", seq_time); //TODO write output points to file -> plot later - //save_matrix(vectors, iterations); + //save_matrix(shifted_points, iterations); } \ No newline at end of file diff --git a/serial_declarations.c b/serial_declarations.c index 3bd388a..c922ddb 100644 --- a/serial_declarations.c +++ b/serial_declarations.c @@ -70,24 +70,35 @@ int meanshift(double **original_points, double ***shifted_points, int h } // create new y vector - double **y_new = alloc_2d_double(NUMBER_OF_POINTS, DIMENSIONS); - - multiply(kernel_matrix, original_points, y_new); + double **new_shift = alloc_2d_double(NUMBER_OF_POINTS, DIMENSIONS); + // build nominator + multiply(kernel_matrix, original_points, new_shift); // divide element-wise for (int i=0; i opt->epsilon) { return meanshift(original_points, shifted_points, h, opt, ++iteration);