1515SC_MODULE (unification_module) {
1616
1717 // -----------Internal variables-------------------
18- int x, y;
19- int *magnitude;
18+ unsigned char x, y;
19+ unsigned char *magnitude;
2020
2121 // -----------Constructor-------------------
2222 SC_CTOR (unification_module) {
2323 } // End of Constructor
2424
2525 // ------------Code Starts Here-------------------------
26- void unificate (int x, int y, int * magnitude) {
26+ void unificate (unsigned char x, unsigned char y, unsigned char * magnitude) {
2727 this ->x = x;
2828 this ->y = y;
2929 this ->magnitude = magnitude;
@@ -34,6 +34,20 @@ SC_MODULE (unification_module) {
3434 // Values are 1byte -> 0 to 255
3535 *(this ->magnitude ) = min (255 ,*(this ->magnitude ));
3636 }
37+
38+ void unificate_img (unsigned char *img_x, unsigned char *img_y, unsigned char *img_unificated, int img_size, int channels){
39+ // Iterate over image
40+ for (unsigned char *x = img_x, *y = img_y, *u = img_unificated; x < img_x + img_size, y < img_y + img_size, u< img_unificated + img_size; x+=channels, y+=channels, u+=channels){
41+ unsigned char pixel_magnitude;
42+ unsigned char pixel_x = *x;
43+ unsigned char pixel_y = *y;
44+ // printf("Operands: Pixel #%0d -> pixel_x = %0d, pixel_y = %0d\n",int(x-img_x), pixel_x, pixel_y);
45+
46+ this ->unificate (pixel_x, pixel_y, &pixel_magnitude);
47+ // printf("RESULT: pixel_magnitude = %d\n", pixel_magnitude);
48+ *u = pixel_magnitude;
49+ }
50+ }
3751
3852 int norm (int a, int b) {
3953 int norm_result = 0 ;
0 commit comments