Skip to content

Commit 1fc5365

Browse files
committed
Reformating files structure to match other modules format
1 parent 0e3ce9e commit 1fc5365

File tree

4 files changed

+104
-89
lines changed

4 files changed

+104
-89
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//-----------------------------------------------------
2+
//Module: Image Unification (PV) Header
3+
//By: Roger Morales Monge
4+
//Description: Programmer's View Model of unification
5+
//process for two images (magnitude)
6+
//-----------------------------------------------------
7+
8+
#ifdef IMG_UNIFICATE_PV_EN
9+
#ifndef IMG_UNIFICATE_HPP
10+
#define IMG_UNIFICATE_HPP
11+
12+
#include "systemc.h"
13+
#include "math.h"
14+
15+
SC_MODULE (img_unification_module) {
16+
17+
//-----------Internal Variables-----------
18+
unsigned char x_pixel, y_pixel;
19+
unsigned char *unificated_pixel;
20+
21+
//-----------Constructor-----------
22+
SC_CTOR(img_unification_module) {
23+
} // End of Constructor
24+
25+
//------------Methods------------
26+
void unificate_pixel(unsigned char x_pixel, unsigned char y_pixel, unsigned char * unificated_pixel);
27+
void unificate_img(unsigned char *x_img, unsigned char *y_img, unsigned char *unificated_img, int img_size, int channels);
28+
int norm(int a, int b);
29+
};
30+
31+
#endif //IMG_UNIFICATE_HPP
32+
#endif //IMG_UNIFICATE_PV_EN
33+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//-----------------------------------------------------
2+
//Module: Unification (PV)
3+
//By: Roger Morales Monge
4+
//Description: Programmer's View Model of unification
5+
//process for two images (magnitude)
6+
//-----------------------------------------------------
7+
#ifdef IMG_UNIFICATE_PV_EN
8+
#ifndef IMG_UNIFICATE_CPP
9+
#define IMG_UNIFICATE_CPP
10+
11+
#include "unification_pv_model.hpp"
12+
13+
//-----------NORM SELECTION MACROS-----------
14+
//#define USE_L1_NORM
15+
#define USE_L2_NORM //default
16+
//#define USE_INF_NORM
17+
//-------------------------------------------
18+
19+
void img_unification_module::unificate_pixel(unsigned char x_pixel, unsigned char y_pixel, unsigned char * unificated_pixel) {
20+
//Get the Norm
21+
*unificated_pixel = (unsigned char) this->norm(x_pixel, y_pixel);
22+
}
23+
24+
void img_unification_module::unificate_img(unsigned char *x_img, unsigned char *y_img, unsigned char *unificated_img, int img_size, int channels){
25+
//Iterate over image
26+
for(unsigned char *x = x_img, *y = y_img, *u = unificated_img; x < x_img + img_size && y < y_img + img_size && u < unificated_img + img_size; x+=channels, y+=channels, u+=channels){
27+
unsigned char pixel_magnitude;
28+
unsigned char pixel_x = int(*x);
29+
unsigned char pixel_y = int(*y);
30+
31+
this->unificate_pixel(pixel_x, pixel_y, &pixel_magnitude);
32+
*u = pixel_magnitude;
33+
}
34+
}
35+
36+
int img_unification_module::norm(int a, int b) {
37+
int norm_result = 0;
38+
39+
//L1 Norm
40+
#ifdef USE_L1_NORM
41+
norm_result = abs(a) + abs(b);
42+
#endif
43+
44+
//L2 Norm
45+
#ifdef USE_L2_NORM
46+
norm_result = sqrt(pow(a, 2) + pow(b, 2));
47+
#endif
48+
49+
//INFINITY Norm
50+
#ifdef USE_INF_NORM
51+
norm_result = (a > b ? a : b);
52+
#endif
53+
54+
return norm_result;
55+
}
56+
57+
#endif //IMG_UNIFICATE_CPP
58+
#endif //IMG_UNIFICATE_PV_EN

modules/unification/unification_tb.cpp renamed to modules/unification/src/unification_tb.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@
33
//By: Roger Morales Monge
44
//Description: Simple TB for pixel unification modules
55
//--------------------------------------------------------
6+
67
#include <systemc.h>
8+
79
#define STB_IMAGE_IMPLEMENTATION
8-
#include "lib/stb_image.h"
10+
#include "include/stb_image.h"
911
#define STB_IMAGE_WRITE_IMPLEMENTATION
10-
#include "lib/stb_image_write.h"
11-
#include "unification_pv_model.cpp"
12-
//#include "unification_lt_model.cpp"
13-
//#include "unification_at_model.cpp"
12+
#include "include/stb_image_write.h"
13+
14+
15+
#include "math.h"
1416

17+
#ifdef IMG_UNIFICATE_PV_EN
18+
#include "unification_pv_model.hpp"
19+
#endif
1520

1621
int sc_main (int argc, char* argv[]) {
1722

18-
int pixel_x, pixel_y;
19-
int pixel_magnitude;
23+
unsigned char pixel_x, pixel_y;
24+
unsigned char pixel_magnitude;
2025
int i;
2126
int width, height, channels, pixel_count;
2227
unsigned char *img_x, *img_y, *img_unificated;
@@ -26,7 +31,7 @@ int sc_main (int argc, char* argv[]) {
2631
int error_count;
2732
float error_med;
2833

29-
unification_module unification_U1 ("unification_U1");
34+
img_unification_module unification_U1 ("unification_U1");
3035

3136
// Open VCD file
3237
sc_trace_file *wf = sc_create_vcd_trace_file("unification_U1");

modules/unification/unification_pv_model.cpp

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)