Skip to content

Commit 09abe45

Browse files
committed
Move img unification to module
1 parent 9171792 commit 09abe45

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

modules/unification/unification_pv_model.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
SC_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;

modules/unification/unification_tb.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,7 @@ int sc_main (int argc, char* argv[]) {
5252
printf("Combined X and Y images...\n");
5353

5454
//Iterate over image
55-
for(unsigned char *x = img_x, *y = img_y, *u = img_unificated; x < img_x + pixel_count, y < img_y + pixel_count, u< img_unificated + pixel_count; x+=channels, y+=channels, u+=channels){
56-
pixel_x = *x;
57-
pixel_y = *y;
58-
//printf("Operands: Pixel #%0d -> pixel_x = %0d, pixel_y = %0d\n",int(x-img_x), pixel_x, pixel_y);
59-
60-
unification_U1.unificate(pixel_x, pixel_y, &pixel_magnitude);
61-
//printf("RESULT: pixel_magnitude = %d\n", pixel_magnitude);
62-
*u = pixel_magnitude;
63-
}
55+
unification_U1.unificate_img(img_x, img_y, img_unificated, pixel_count, channels);
6456
printf("Unification finished.\n");
6557
//FIXME: Add comparison with reference combined image, and time measurement
6658

0 commit comments

Comments
 (0)