-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
235 lines (203 loc) · 8.27 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
//
// main.cpp
// Przetwarzanie_obrazów_1
//
// Created by Michał on 22.06.2018.
// Copyright © 2018 Michał. All rights reserved.
//
#include <time.h>
#include <string.h>
#include "obsluga_obrazu.h"
#include "przetwarzanie_obrazu.h"
#include "filtrowanie_obrazu.h"
int main(void){
int obraz[MAX][MAX];
char komentarze[DL_LINII][DL_LINII];
char nazwa_pliku[20] = "brak";
int wymx = 0, wymy = 0, szarosci = 0;
int prog = 0;
int czern = 0;
int biel = 0;
float gamma = 0;
FILE *plik = NULL;
char nazwa[20] = "brak";
int wybor = 0;
while(wybor != 99){
printf("----- Przetwarzanie obrazow 1 -----\n\n");
printf("Wczytany obraz: %s \n",nazwa_pliku);
printf("Rozmiar obrazu: %d x %d \n",wymx,wymy);
printf("Maksymalny odcien szarosci: %d \n",szarosci);
printf("\n---------- Opcje programu ---------\n\n");
printf("1. Wczytaj obraz \n");
printf("2. Zapisz obraz do pliku \n");
printf("3. Wyswietl obraz \n\n");
printf("4. -> Negatyw \n");
printf("5. -> Progowanie \n");
printf("6. -> Progowanie czerni \n");
printf("7. -> Progowanie bieli \n");
printf("8. -> Korekcja gamma \n");
printf("9. -> Zmiana poziomow \n");
printf("10. -> Konturowanie \n");
printf("11. -> Rozmywanie poziome \n");
printf("12. -> Rozmywanie pionowe \n");
printf("13. -> Rozciaganie histogramu \n\n");
printf("14. -> Filtr usredniajacy \n");
printf("15. -> Filtr usredniajacy ze wzmocnieniem \n");
printf("16. -> Gradient Robertsa \n");
printf("17. -> Pozioma maska Prewitta \n");
printf("18. -> Maska Sobela \n");
printf("19. -> Maska wykrywajaca narozniki \n");
printf("20. -> Laplasjan \n\n");
printf("99. Zakoncz ");
printf("\n-----------------------------------\n");
printf("Twoj wybor > ");
scanf("%d",&wybor);
time_t czas;
struct tm * ptr;
time( & czas );
ptr = localtime( & czas );
char * data = asctime( ptr );
switch(wybor){
case 1:
printf("Podaj nazwe pliku: ");
scanf("%s",nazwa);
plik = fopen(nazwa,"r");
if (plik != NULL) {
if(czytaj(plik,obraz,&wymx,&wymy,&szarosci,komentarze) == 1){
strcpy(nazwa_pliku,nazwa);
}
fclose(plik);
}
break;
case 2:
printf("Podaj nazwe pliku: ");
scanf("%s",nazwa);
plik = fopen(nazwa,"w");
if (plik != NULL) {
zapisz(plik,obraz,&wymx,&wymy,&szarosci,komentarze);
fclose(plik);
}
break;
case 3:
wyswietl(nazwa);
break;
case 4:
negatyw(obraz,&wymx,&wymy,&szarosci);
char komentarz1[50] = " Negatyw ";
strcat(komentarz1,data);
dodaj_komentarz(komentarze,komentarz1);
break;
case 5:
printf("Podaj wartosc progu: ");
scanf("%d",&prog);
progowanie(obraz,&wymx,&wymy,&szarosci,prog);
char komentarz2[50] = " Progowanie ";
strcat(komentarz2,data);
dodaj_komentarz(komentarze,komentarz2);
break;
case 6:
printf("Podaj wartosc progu: ");
scanf("%d",&prog);
progowanie_czerni(obraz,&wymx,&wymy,&szarosci,prog);
char komentarz3[50] = " Progowanie czerni ";
strcat(komentarz3,data);
dodaj_komentarz(komentarze,komentarz3);
break;
case 7:
printf("Podaj wartosc progu: ");
scanf("%d",&prog);
progowanie_bieli(obraz,&wymx,&wymy,&szarosci,prog);
char komentarz4[50] = " Progowanie bieli ";
strcat(komentarz4,data);
dodaj_komentarz(komentarze,komentarz4);
break;
case 8:
printf("Podaj wspolczynnik gamma: ");
scanf("%f",&gamma);
korekcja_gamma(obraz,&wymx,&wymy,&szarosci,gamma);
char komentarz5[50] = " Korekcja gamma ";
strcat(komentarz5,data);
dodaj_komentarz(komentarze,komentarz5);
break;
case 9:
printf("Podaj wartosc poziomu czerni: ");
scanf("%d",&czern);
printf("Podaj wartosc poziomu bieli: ");
scanf("%d",&biel);
zmiana_poziomow(obraz,&wymx,&wymy,&szarosci,czern,biel);
char komentarz6[50] = " Zmiana poziomow ";
strcat(komentarz6,data);
dodaj_komentarz(komentarze,komentarz6);
break;
case 10:
konturowanie(obraz,&wymx,&wymy);
char komentarz7[50] = " Konturowanie ";
strcat(komentarz7,data);
dodaj_komentarz(komentarze,komentarz7);
break;
case 11:
rozmywanie_poziome(obraz,&wymx,&wymy);
char komentarz8[50] = " Rozmywanie poziome ";
strcat(komentarz8,data);
dodaj_komentarz(komentarze,komentarz8);
break;
case 12:
rozmywanie_pionowe(obraz,&wymx,&wymy);
char komentarz9[50] = " Rozmywanie pionowe ";
strcat(komentarz9,data);
dodaj_komentarz(komentarze,komentarz9);
break;
case 13:
rozciaganie_histogramu(obraz,&wymx,&wymy,&szarosci);
char komentarz10[50] = " Rozciaganie histogramu ";
strcat(komentarz10,data);
dodaj_komentarz(komentarze,komentarz10);
break;
case 14:
filtr_usredniajacy(obraz,&wymx,&wymy);
char komentarz11[50] = " Filtr usredniajacy ";
strcat(komentarz11,data);
dodaj_komentarz(komentarze,komentarz11);
break;
case 15:
filtr_usredniajacy_ze_wzmocnieniem(obraz,&wymx,&wymy);
char komentarz12[50] = " Filtr usredniajacy ze wzmocnieniem ";
strcat(komentarz12,data);
dodaj_komentarz(komentarze,komentarz12);
break;
case 16:
gradient_robertsa(obraz,&wymx,&wymy);
char komentarz13[50] = " Gradient Robertsa ";
strcat(komentarz13,data);
dodaj_komentarz(komentarze,komentarz13);
break;
case 17:
pozioma_maska_prewitta(obraz,&wymx,&wymy);
char komentarz14[50] = " Pozioma maska Prewitta ";
strcat(komentarz14,data);
dodaj_komentarz(komentarze,komentarz14);
break;
case 18:
maska_sobela(obraz,&wymx,&wymy);
char komentarz15[50] = " Maska Sobela ";
strcat(komentarz15,data);
dodaj_komentarz(komentarze,komentarz15);
break;
case 19:
maska_wykrywajaca_narozniki(obraz,&wymx,&wymy);
char komentarz16[50] = " Maska wykrywajaca narozniki ";
strcat(komentarz16,data);
dodaj_komentarz(komentarze,komentarz16);
break;
case 20:
laplasjan(obraz,&wymx,&wymy);
char komentarz17[50] = " Laplasjan ";
strcat(komentarz17,data);
dodaj_komentarz(komentarze,komentarz17);
break;
}
system("clear");
}
printf("Program zakonczyl dzialanie\n");
return 0;
}