-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
144 lines (88 loc) · 3.3 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "lectorBmp.h"
#include "filtros.h"
extern int asmPrint
(char * msg, int lenght);
int asm_Print(char * msg){
return asmPrint(msg,strlen(msg));
}
/******************************************************************************/
int main (int argc, char* argv[]) {
asm_Print("Organización del Computador 2.\nTrabajo Práctico Nro. 2\nPrograma para procesamiento de imágenes BMP.\n");
int resolucion = 1080;
BMPDATA bmpData;
BMPDATA bmpData2;
BMPDATA bmpData3;
BMPDATA bmpData4;
int i;
/*printf("Ejecutando con parametros: ");
for (i=1 ; i<argc; i++){
printf("%s ", argv[i]);
}*/
clock_t start, end;
// comienza a medir el tiempo
start = clock();
//Funcion blanco y negro---------------------------------------------------------------------
if (loadBmpFile ("lena.bmp", &bmpData) != 0) {
printf ("Error al leer el archivo %s\n\n", "lena.bmp");
return 1;
}
blancoYNegro (&bmpData);
if (saveBmpFile ("lenaEnGrises.bmp", &bmpData) != 0)
asm_Print("Error al grabar el archivo!");
//Funcion aclarar---------------------------------------------------------------------
if (loadBmpFile ("lena.bmp", &bmpData) != 0) {
printf ("Error al leer el archivo %s\n\n", "lena.bmp");
return 1;
}
aclarar(&bmpData,50);
if (saveBmpFile ("lenaAclarada.bmp", &bmpData) != 0)
asm_Print("Error al grabar el archivo!");
//Negativo---------------------------------------------------------------------
if(loadBmpFile("lena.bmp",&bmpData)!= 0){
printf ("Error al leer el archivo %s\n\n", "lena.bmp");
return 1;
}
negativo(&bmpData);
if (saveBmpFile ("lenaNegativo.bmp", &bmpData) != 0)
asm_Print("Error al grabar el archivo!");
//Median Filter------------------------------------------------------------------
if (loadBmpFile ("lena_corrupted.bmp", &bmpData) != 0) {
printf ("Error al leer el archivo %s\n\n", "lena_corrupted.bmp");
return 1;
}
medianFilter(&bmpData);
if (saveBmpFile ("lenaMedianFilter.bmp", &bmpData) != 0)
asm_Print("Error al grabar el archivo!");
//Blend------------------------------------------------------------------------------------
if (loadBmpFile("imagen_1.bmp",&bmpData2)!=0)
printf("Error al leer el archivo %s\n\n","imagen_1.bmp");
if (loadBmpFile("imagen_2.bmp",&bmpData3)!=0)
printf("Error al leer el archivo %s\n\n","imagen_2.bmp");
blend(&bmpData2,&bmpData3);
if (saveBmpFile ("Imagen1_2Blended.bmp", &bmpData2) != 0)
asm_Print("Error al grabar el archivo!");
//Blend_asm------------------------------------------------------------------------------------
if (loadBmpFile("imagen_1.bmp",&bmpData2)!=0)
printf("Error al leer el archivo %s\n\n","imagen_1.bmp");
if (loadBmpFile("imagen_2.bmp",&bmpData3)!=0)
printf("Error al leer el archivo %s\n\n","imagen_2.bmp");
blendASM(&bmpData2,&bmpData3);
if (saveBmpFile ("Imagen1_2BlendedASM.bmp", &bmpData3) != 0)
asm_Print("Error al grabar el archivo!");
end = clock();
FILE *out = fopen("results.csv", "a");
int tiempo = end-start;
fprintf(out, "%d %s %d", resolucion, " tiempo: ", tiempo );
fclose(out);
// imprime tiempo
printf("\nTiempo de proceso: %ld ticks.\n\n", end-start);
// libera memoria
limpiarBmpData(&bmpData);
return 0;
}