|
6 | 6 | #include "file_operations.h"
|
7 | 7 |
|
8 | 8 | int main(int argc, char *argv[]) {
|
9 |
| - char *file_in, *file_out, *file_out_h, *file_out_v, *file_gray; |
10 |
| - int inter_files = 0, gray_file = 0; |
11 |
| - byte *rgb, *gray; |
12 |
| - int rgb_size, gray_size; |
13 |
| - int sobel_h[] = {1, 0, -1, 2, 0, -2, 1, 0, -1}, |
14 |
| - sobel_v[] = {1, 2, 1, 0, 0, 0, -1, -2, -1}; |
15 |
| - byte *sobel_h_res, *sobel_v_res; |
16 |
| - byte *contour_img; |
| 9 | + char *file_in, |
| 10 | + *file_out, |
| 11 | + *file_out_h, |
| 12 | + *file_out_v, |
| 13 | + *file_gray; |
| 14 | + |
| 15 | + byte *rgb, |
| 16 | + *gray, |
| 17 | + *sobel_h_res, |
| 18 | + *sobel_v_res, |
| 19 | + *contour_img; |
| 20 | + |
| 21 | + int inter_files = 0, |
| 22 | + gray_file = 0; |
17 | 23 |
|
18 | 24 | // Get arguments
|
19 | 25 | if(argc < 3) {
|
@@ -61,29 +67,21 @@ int main(int argc, char *argv[]) {
|
61 | 67 | }
|
62 | 68 |
|
63 | 69 | // Read file to rgb and get size
|
64 |
| - rgb_size = readFile(file_in, &rgb); |
| 70 | + int rgb_size = readFile(file_in, &rgb); |
65 | 71 |
|
66 |
| - // Get gray representation of the image |
67 |
| - gray_size = rgbToGray(rgb, &gray, rgb_size); |
| 72 | + int gray_size = sobelFilter(rgb, &gray, &sobel_h_res, &sobel_v_res, &contour_img, rgb_size); |
68 | 73 |
|
69 | 74 | // Write gray image
|
70 | 75 | if(gray_file) {
|
71 | 76 | writeFile(file_gray, gray, gray_size);
|
72 | 77 | }
|
73 | 78 |
|
74 |
| - // Make sobel operations |
75 |
| - itConv(gray, gray_size, sobel_h, &sobel_h_res); |
76 |
| - itConv(gray, gray_size, sobel_v, &sobel_v_res); |
77 |
| - |
78 | 79 | // Write image after each sobel operator
|
79 | 80 | if(inter_files) {
|
80 | 81 | writeFile(file_out_h, sobel_h_res, gray_size);
|
81 | 82 | writeFile(file_out_v, sobel_v_res, gray_size);
|
82 | 83 | }
|
83 | 84 |
|
84 |
| - // Calculate contour matrix |
85 |
| - contour(sobel_h_res, sobel_v_res, gray_size, &contour_img); |
86 |
| - |
87 | 85 | // Write sobel img to a file
|
88 | 86 | writeFile(file_out, contour_img, gray_size);
|
89 | 87 |
|
|
0 commit comments