Skip to content

Commit ca4e985

Browse files
jgavillalobosErickOF
authored andcommitted
Use RGB noisy image in TB
1 parent fc430d9 commit ca4e985

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

modules/compression/include/ips_jpg_pv_model.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ SC_MODULE (jpg_output) {
8181
image[i]=image[i]-128;
8282
}
8383
int number_of_blocks = image_rows*image_cols/(BLOCK_ROWS*BLOCK_COLS);
84-
printf("number_of_block %0d ROWS %0d COLS %0d\n", number_of_blocks, BLOCK_ROWS, BLOCK_COLS);
8584
#ifndef USING_TLM_TB_EN
8685
int block_output[number_of_blocks][BLOCK_ROWS*BLOCK_COLS] = {0};
8786
int block_output_size[number_of_blocks] = {0};

modules/router/src/tb_edge_detector_tlm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ SC_MODULE(Tb_top)
114114

115115
signed char* compression_results;
116116

117-
colorImage = imread("../../tools/datagen/src/imgs/car.jpg", IMREAD_UNCHANGED);
117+
colorImage = imread("../../tools/datagen/src/imgs/car_rgb_noisy_image.jpg", IMREAD_UNCHANGED);
118118

119119
if (colorImage.empty())
120120
{
@@ -890,4 +890,4 @@ int sc_main(int, char*[])
890890
}
891891
#endif // TB_EDGE_DETECTOR_TLM_CPP
892892
#endif // USING_TLM_TB_EN
893-
#endif // USING_TLM_ROUTER_TB_EN
893+
#endif // USING_TLM_ROUTER_TB_EN

tools/datagen/datagen.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
import numpy as np
99
import matplotlib.pyplot as plt
1010

11+
import cv2
12+
import numpy as np
13+
14+
def add_gaussian_noise(
15+
image_path: str,
16+
mean: float = 0,
17+
stddev: float = 0.5
18+
) -> np.ndarray:
19+
# Read the image
20+
image: np.ndarray = cv2.imread(image_path)
21+
noise = np.random.normal(mean, stddev, image.shape).astype(np.uint8)
22+
noisy_image = cv2.add(image, noise)
23+
return noisy_image
1124

1225
def apply_sobel_filter(
1326
image_path: str,
@@ -101,7 +114,7 @@ def apply_sobel_filter(
101114
plt.imshow(sobel_combined_uint8, cmap='gray')
102115
plt.axis('off')
103116

104-
plt.show()
117+
# plt.show()
105118

106119
return (gray_img, noisy_img, sobel_x_uint8, sobel_y_uint8,
107120
sobel_combined_uint8)
@@ -110,6 +123,8 @@ def apply_sobel_filter(
110123
if __name__ == '__main__':
111124
salt_probability: float = 0.1
112125
pepper_probability: float = 0.1
126+
gaussian_mean: float = 0
127+
gaussian_stddev: float = 0.5
113128
img_name: str = 'car'
114129
img_ext: str = 'jpg'
115130
img_path: str = f'src/imgs/{img_name}.{img_ext}'
@@ -130,3 +145,7 @@ def apply_sobel_filter(
130145
f'src/imgs/{img_name}_sobel_combined_result.{img_ext}',
131146
sobel_combined
132147
)
148+
149+
noisy_rgb = add_gaussian_noise(img_path, gaussian_mean, gaussian_stddev)
150+
151+
cv2.imwrite(f'src/imgs/{img_name}_rgb_noisy_image.{img_ext}', noisy_rgb)

0 commit comments

Comments
 (0)