-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageProcessor.cpp
More file actions
1799 lines (1499 loc) · 50 KB
/
Copy pathImageProcessor.cpp
File metadata and controls
1799 lines (1499 loc) · 50 KB
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include<iostream>
#include<fstream>
#include<string>
#include<cstdlib>
#include<cmath>
using namespace std;
bool Saved = false;
#define MaxRows 500
#define MaxCols 500
struct grayImage {
grayImage() {
/*
The constructor function that is used to initialize the structure variables
*/
Rows = Cols = 0;
loaded = false;
for (int r = 0; r < MaxRows; r++)
for (int c = 0; c < MaxCols; c++)
Image[r][c] = 0;
}
int setPixel(unsigned short value, int r, int c)
{
if (r >= Rows || c >= Cols || r < 0 || c < 0)
return -1;
Image[r][c] = value;
return value;
}
int getPixel(int r, int c)
{
if (r >= Rows || c >= Cols || r < 0 || c < 0)
return -1;
return Image[r][c];
}
int setRows(int rows)
{
if (rows < 1 || rows > MaxRows)
return -1;
Rows = rows;
return Rows;
}
int getRows()
{
return Rows;
}
int setCols(int cols)
{
if (cols < 1 || cols > MaxCols)
return -1;
Cols = cols;
return Cols;
}
int getCols()
{
return Cols;
}
int Save(string File_Name)
{
/*
This function will create an ASCII pgm file
and store the contents of the the image in it
Function must
return 0 if successful
1 if File_Name is not correct {it must end as .pgm}
2 if unable to create a file
*/
ofstream OUT(File_Name.c_str());
if (File_Name.substr(File_Name.find_last_of(".") + 1) == "pgm")
{
loaded = true;
}
else
{
cout << "Error while saving ! .\nUnable to Save file (.pgm extension is missing) !\n\n";
return 1;
}
if (loaded == true)
{
OUT << "P2" << endl;
OUT << "# created by CodeXOwls" << endl;
OUT << Cols << " " << Rows << endl;
OUT << Maximum << endl;
for (int i = 0; i < Rows; i++)
{
for (int j = 0; j < Cols; j++)
{
OUT << Image[i][j] << " ";
}
OUT << endl;
}
return 0;
OUT.close();
}
else
{
cout << "Image not loaded ! \n\n";
return 2;
}
}
int load(string File_Name)
{
/*
This function will read contents of an ASCII pgm file
and store these contents in the variable and arry
declared in this struct
return 0 if successful
1 if File_Name is not correct {it must end as .pgm}
2 if unable to open the file for reading
*/
string s;
ifstream IN(File_Name.c_str());
getline(IN, s);
getline(IN, s);
IN >> Cols >> Rows >> Maximum;
int C, R;
if (File_Name.substr(File_Name.find_last_of(".") + 1) == "pgm")
{
loaded = true;
}
else
{
cout << "Check Image(s) extension \n\n";
return 1;
}
if (IN.is_open())
{
for (int i = 0; i < Rows; i++)
{
for (int j = 0; j < Cols; j++)
{
IN >> Image[i][j];
}
}
C = setCols(Cols);
if (C == -1)
{
cout << "Error: Check Cols \n\n" << endl;
return 2;
}
R = setRows(Rows);
if (R == -1)
{
cout << "Error: Check Rows \n\n" << endl;
return 2;
}
loaded = true;
}
else
{
cout << "Cannot load image(s) \n\n ";
return 2;
}
IN.close();
return 0;
}
void combineSideBySide(grayImage& Two, string FileName, unsigned short fillValue = 0) {
int N = MaxCols - Cols;
int C, colfrom;
if (N > Two.Cols)
{
C = Cols + Two.Cols;
}
else
{
C = Cols + N;
}
int R;
if (Rows > Two.Rows)
{
R = Rows;
}
else
{
R = Two.Rows;
}
int coltill, rowfrom;
if (Rows < Two.Rows)
{
rowfrom = Rows;
colfrom = 0;
coltill = Cols;
}
else
{
rowfrom = Two.Rows;
colfrom = Cols;
coltill = C;
}
for (int i = 0; i < Two.Rows; i++)
{
for (int j = 0; j < N; j++)
{
Image[i][j + Cols] = Two.Image[i][j];
}
}
for (int i = rowfrom; i < R; i++)
{
for (int j = colfrom; j < coltill; j++)
{
Image[i][j] = { fillValue };
}
}
Rows = R;
Cols = C;
if (R > MaxRows || C > MaxCols)
{
cout << " Error while saving ! .\n.While combining exceeded 500 by 500 space ";
return;
}
Save(FileName);
}
void combineTopToBottom(grayImage& Two, string FileName, unsigned short fillValue = 0) {
/*
This function must combine two images placing the first image on top and the second images
on bottom.
You must remember that the two images might not be equal in size and in such a case the
the smaller image must be left-aligned with the larger image filling any extra columns
with the gray color specified by the fillValue argument
*/
int N = MaxRows - Rows;
int R, colfrom;
if (N > Two.Rows)
{
R = Rows + Two.Rows;
}
else
{
R = Rows + N;
}
int C;
int coltill, rowfrom, rowtill;
if (Cols > Two.Cols)
{
C = Cols;
rowfrom = Rows;
coltill = C;
colfrom = Two.Cols;
}
else
{
C = Two.Cols;
coltill = C;
colfrom = Cols;
rowfrom = 0;
}
if (Rows < Two.Rows)
{
rowtill = Rows;
}
else
{
rowtill = R;
}
if (R > MaxRows || C > MaxCols)
{
cout << " Error while saving ! .\n.While combining exceeded 500 by 500 space ";
return;
}
for (int i = 0; i < N; i++)
{
for (int j = 0; j < C; j++)
{
Image[i + Rows][j] = Two.Image[i][j];
}
}
for (int i = rowfrom; i < rowtill; i++)
{
for (int j = colfrom; j < coltill; j++)
{
Image[i][j] = { fillValue };
}
}
Rows = R;
Cols = C;
Save(FileName);
}
void FadeIn(grayImage& second, int seconds, string BaseFileName, int frameRate = 30 ) {
/*
This function generate a sequence of seconds*frameRate images by taking average of corresponding pixel values
Your first image must be the starting image and you must keep on creating new intermediate images by taking the
average such that the second image gradually appears and first image fades away.
Once again the two images might not be equal in size and in such a case the centers of the two images must be aligned.
Here you can start by assuming that the two images have same size and relax the assumption later.
*/
grayImage H;
double StepSize = 1.0 / (frameRate * seconds);
int Counter=0;
int R,C,M;
R = Rows;
if (second.Rows > Rows)
{
R = second.Rows;
}
C = Cols;
if (second.Cols > Cols)
{
C = second.Cols;
}
M = Maximum;
if (second.Maximum > Maximum)
{
M = second.Maximum;
}
H.Rows = R;
H.Cols = C;
H.Maximum = M;
for (double Alpha=1 ; Alpha >=0 ;Alpha-=StepSize)
{
for (int r = 0; r < R; r++)
{
for (int c = 0; c < C; c++)
{
H.Image[r][c] = Image[r][c] * Alpha + (1 - Alpha) * second.Image[r][c];
}
}
char N[10];
itoa(Counter, N, 10);
H.Save(BaseFileName + N + ".pgm");
Counter++;
/* if (Alpha - StepSize<0 && Alpha - StepSize>-StepSize)
{
Alpha = 0;
}*/
}
}
void Rotate(grayImage& RotatedImage, double angle = 90, int aboutx = 0, int abouty = 0)
{
/* This Function Has four explicit parameters
angle : for counter clockwise direction the angle will be positive and negative for the clockwise direction
aboutx and abouty: are the two points specifying the center of rotation
RotatedImage: is a reference of a grayImage variable/structure. The rotated image will be placed in it
*/
int in, jn;
angle = (angle * 3.1415192) / 180;
RotatedImage.Rows = Rows;
RotatedImage.Cols = Cols;
RotatedImage.Maximum = Maximum;
for (int i = 0; i < Rows; i++)
{
for (int j = 0; j < Cols; j++)
{
if (aboutx == 0 && abouty == 0)
{
if (Rows % 2 == 0)
{
aboutx = Rows / 2;
}
else
{
aboutx = (Rows / 2) + 1;
}
if (Cols % 2 == 0)
{
abouty = Cols / 2;
}
else
{
abouty = (Cols / 2) + 1;
}
}
in = ((i - aboutx) * cos(angle) - (j - abouty) * sin(angle)) + aboutx;
jn = ((j - abouty) * cos(angle) + (i - aboutx) * sin(angle) + abouty);
if (in > 0 && in < MaxRows && jn>0 && jn < MaxCols)
{
RotatedImage.Image[in][jn] = Image[i][j];
}
}
}
}
void Flip(int HorizontalOrVertical) {
/*
Parameter HorizontalOrVertical will be used to specify if the flip will be a horizontal flip or a vertical flip;
The function will use one of the two private flip functions to do the task;
*/
if (HorizontalOrVertical == 0)
{
FilpHorizontal();
}
else if (HorizontalOrVertical == 1)
{
FlipVerttical();
}
}
void Negative() {
/*
Compute Negative image of an Image
*/
for (int i = 0; i < Rows; i++)
{
for (int j = 0; j < Cols; j++)
{
Image[i][j] = Maximum - (Image[i][j]);
}
}
}
void changeBrightness(int amount) {
/*
Change the brightness level of an image by the amount specified by
the amount parameter
*/
int Check;
for (int i = 0; i < Rows; i++)
{
for (int j = 0; j < Cols; j++)
{
Check = Image[i][j];
if (amount > 0)
{
if ((Check + amount) <= 255)
{
Image[i][j] = Image[i][j] + amount;
}
else
{
Image[i][j] = 255;
}
}
else if (amount < 0)
{
if ((Check + (amount)) > 0)
{
Image[i][j] = Image[i][j] + amount;
}
else
{
Image[i][j] = 0;
}
}
}
}
}
void Quantize(int Levels) {
/*
Apply the quantization
*/
int l;
l = 256 / Levels;
for (int i = 0; i < Rows; i++)
{
for (int j = 0; j < Cols; j++)
{
Image[i][j] = (Image[i][j] / l) * l;
}
}
}
void sortArray(int arrA[], int n)
{
int temp;
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++)
{
if (arrA[i] > arrA[j])
{
temp = arrA[i];
arrA[i] = arrA[j];
arrA[j] = temp;
}
}
}
}
void medianFilter(grayImage& Result, int filterSize = 3) {
/*
Apply median Filtering
*/
int A[9];
for (int i = 1; i <= Rows; i++)
{
for (int j = 1; j <= Cols; j++)
{
if (Image[i][j] == 0 || Image[i][j] == 255)
{
A[0] = Image[i - 1][j];
A[1] = Image[i - 1][j - 1];
A[2] = Image[i - 1][j + 1];
A[3] = Image[i][j - 1];
A[4] = Image[i][j + 1];
A[5] = Image[i][j];
A[6] = Image[i + 1][j + 1];
A[7] = Image[i + 1][j];
A[8] = Image[i + 1][j - 1];
sortArray(A, 9);
Result.Image[i][j] = A[4];
}
else {
Result.Image[i][j] = Image[i][j];
}
}
}
Result.Cols = Cols;
Result.Rows = Rows;
Result.Maximum = Maximum;
}
void meanFilter(grayImage& Result, int filterSize = 3) {
/*
Apply mean Filtering
*/
int A[9];
int mean = 0;
for (int i = 1; i <= Rows; i++)
{
for (int j = 1; j <= Cols; j++)
{
if (Image[i][j] < 200)
{
A[0] = Image[i - 1][j];
A[1] = Image[i - 1][j - 1];
A[2] = Image[i - 1][j + 1];
A[3] = Image[i][j - 1];
A[4] = Image[i][j + 1];
A[5] = Image[i][j];
A[6] = Image[i + 1][j + 1];
A[7] = Image[i + 1][j];
A[8] = Image[i + 1][j - 1];
for (int k = 0; k < 9; k++)
{
mean += A[k];
}
mean = mean / 9;
Result.Image[i][j] = mean;
}
}
}
Result.Cols = Cols;
Result.Rows = Rows;
Result.Maximum = Maximum;
}
void Resize(grayImage& Result, int NR, int NC) {
/*
Change the number of rows to NewRows and Columns to New Columns
*/
double colR, rowR;
colR = NC;
colR = colR / Cols;
rowR = NR;
rowR = rowR / Rows;
for (int i = 0; i < NR; i++)
{
for (int j = 0; j < NC; j++)
{
int I, J;
I = i / rowR;
J = j / colR;
Result.Image[i][j] = Image[I][J];
}
}
Result.Cols = NC;
Result.Rows = NR;
Result.Maximum = 255;
}
void Resize(grayImage& Result, double Ratio) {
/*
Change the rows and columns by the ratio
*/
int NR = Rows * Ratio;
int NC = Cols * Ratio;
if (NR > MaxRows || NC > MaxCols)
{
cout << " Error while saving ! .\n Exceeded limit of 500 by 500 while resizing !";
return;
}
if (NR == 0 || NC == 0)
{
return;
}
Resize(Result, NR, NC);
}
void Transform(grayImage& Result, double Matrix[3][3]) {
/*
Apply General transformation represented by the matrix
*/
double I, J,Z;
int NI, NJ;
for (int i = 0; i < Rows; i++)
{
for (int j = 0 ; j < Cols; j++)
{
I = ((i * Matrix[0][0]) + (j * Matrix[0][1]) + (Matrix[0][2]));
J = ((i * Matrix[1][0]) + (j * Matrix[1][1]) + (Matrix[1][2]));
Z= ((i * Matrix[2][0]) + (j * Matrix[2][1]) + (Matrix[2][2]));
NI = I / Z;
NJ = J / Z;
if (NI >= 0 && NJ >= 0 && NI < MaxRows && NJ < MaxCols)
{
Result.Image[NI][NJ] = Image[i][j];
}
}
}
Result.Rows = MaxRows;
Result.Cols = MaxCols;
Result.Maximum = Maximum;
}
void Filter(double Mask[3][3]) {
/*
Apply The filter mask on the image
*/
double A;
for (int i = 1; i <= Rows-1; i++)
{
for (int j = 1; j <= Cols-1; j++)
{
A = Image[i - 1][j - 1] * Mask[0][0];
A = A + (Image[i - 1][j] * Mask[0][1]);
A = A + (Image[i - 1][j+1] * Mask[0][2]);
A = A + (Image[i][j-1] * Mask[1][0]);
A = A + (Image[i][j] * Mask[1][1]);
A = A + (Image[i][j+1] * Mask[1][2]);
A = A + (Image[i+1][j -1] * Mask[2][0]);
A = A + (Image[i + 1][j] * Mask[2][1]);
A = A + (Image[i + 1][j + 1] * Mask[2][2]);
Image[i][j] = A;
}
}
}
void DerivativeImage(grayImage& Result) {
double V1, V2,D;
double H[3][3] = { {-1,-1,-1},{0,0,0},{1,1,1} };
double V[3][3] = { {-1,0,1},{-1,0,1},{-1,0,1} };
for (int i = 1; i <= Rows - 1; i++)
{
for (int j = 1; j <= Cols - 1; j++)
{
V1 = Image[i - 1][j - 1] * H[0][0];
V1 = V1 + (Image[i - 1][j] * H[0][1]);
V1 = V1 + (Image[i - 1][j + 1] * H[0][2]);
V1 = V1 + (Image[i][j - 1] * H[1][0]);
V1 = V1 + (Image[i][j] * H[1][1]);
V1 = V1 + (Image[i][j + 1] * H[1][2]);
V1 = V1 + (Image[i + 1][j - 1] * H[2][0]);
V1 = V1 + (Image[i + 1][j] * H[2][1]);
V1 = V1 + (Image[i + 1][j + 1] * H[2][2]);
V2 = Image[i - 1][j - 1] * V[0][0];
V2 = V2 + (Image[i - 1][j] * V[0][1]);
V2 = V2 + (Image[i - 1][j + 1] * V[0][2]);
V2 = V2 + (Image[i][j - 1] * V[1][0]);
V2 = V2 + (Image[i][j] * V[1][1]);
V2 = V2 + (Image[i][j + 1] * V[1][2]);
V2 = V2 + (Image[i + 1][j - 1] * V[2][0]);
V2 = V2 + (Image[i + 1][j] * V[2][1]);
V2 = V2 + (Image[i + 1][j + 1] * V[2][2]);
D = sqrt((V1 * V1) + (V2 * V2));
Result.Image[i][j] = D;
}
}
Result.Rows = Rows;
Result.Cols = Cols;
Result.Maximum = Maximum;
}
void Crop(grayImage& Result, int T, int L, int R, int B)
{
Result.Rows = B - T;
Result.Cols = R - L;
Result.Maximum = Maximum;
for (int i = 0; i < Result.Rows; i++)
{
for (int j = 0; j < Result.Cols; j++)
{
Result.Image[i][j] = Image[i+T][j+L];
}
}
}
private:
void FilpHorizontal() {
/*
Function for performing horizontal flip;
}*/
int Temp;
for (int i = 0; i < Rows; i++)
{
for (int j = 0; j < Cols / 2; j++)
{
Temp = Image[i][Cols - j];
Image[i][Cols - j] = Image[i][j];
Image[i][j] = Temp;
}
}
}
void FlipVerttical() {
/*
Function for performing Vertical flip;
*/
int Temp;
for (int i = 0; i < Rows / 2; i++)
{
for (int j = 0; j < Cols; j++)
{
Temp = Image[Rows - i][j];
Image[Rows - i][j] = Image[i][j];
Image[i][j] = Temp;
}
}
}
void Fill(int L, int T, int R, int B, int FillValue) {
for (int i = T; i <= B; i++)
for (int j = L; j <= R; j++)
Image[i][j] = FillValue;
}
unsigned short Image[MaxRows][MaxCols];
int Rows, Cols, Maximum;
bool loaded;
};
int main()
{
int Choice,ChoiceLoad,ChoiceSave, CombineChoiceS, CombineChoiceT,fr,sec,ChoiceF;
cout << "\t\t\t\tWelcome to CodeXOwls Photo Editor" << endl;
cout << "\t\t\t\t\t\tMenu " << endl;
cout << "\t\t\t\tPress 0 : To load first Image " << endl;
cout << "\t\t\t\tPress 1 : To Save Image " << endl;
cout << "\t\t\t\tPress 2 : To combine Images Side by Side " << endl;
cout << "\t\t\t\tPress 3 : To combine Images Top to Bottom " << endl;
cout << "\t\t\t\tPress 4 : To Apply Fade In transition " << endl;
cout << "\t\t\t\tPress 5 : To Rotate Image " << endl;
cout << "\t\t\t\tPress 6 : To Flip Image Horizontally " << endl;
cout << "\t\t\t\tPress 7 : To Flip Image Vertically " << endl;
cout << "\t\t\t\tPress 8 : For Negative of Image " << endl;
cout << "\t\t\t\tPress 9 : To change Brightness of Image " << endl;
cout << "\t\t\t\tPress 10: For Quantize Image " << endl;
cout << "\t\t\t\tPress 11: To Apply Median Filter to Image " << endl;
cout << "\t\t\t\tPress 12: To Apply Mean Filter to Image " << endl;
cout << "\t\t\t\tPress 13: To Resize Image By Rows And Columns " << endl;
cout << "\t\t\t\tPress 14: To Resize Image by Ratio " << endl;
cout << "\t\t\t\tPress 15: To Transform Image " << endl;
cout << "\t\t\t\tPress 16: To Apply Filter To Image " << endl;
cout << "\t\t\t\tPress 17: For Derivative Image " << endl;
cout << "\t\t\t\tPress 18: To Crop Image " << endl;
string filename;
string savename,Combinename,Fade;
bool S1=false, S2=false;
grayImage Image1, Image2, Extra1, Extra2;
cout << "Enter your Choice " << endl;
cin >> Choice;
cout << endl;
while (Choice != -1)
{
if (Choice == 0)
{
cout << " Press 1 : If this is your first image ." << endl;
cout << " Press 2 : If this is your second image . " << endl;
cin >> ChoiceLoad;
cout << " Enter name for loading file" << endl;
cin >> filename;
if (ChoiceLoad == 1)
{
int R=0;
R=Image1.load(filename);
if (R == 0)
{
S1 = true;
cout << "\n\n Successfully loaded Image 1" << endl;
}
else
{
return R;
}
}
else if (ChoiceLoad == 2)
{
int R=0;
R=Image2.load(filename);
if (R == 0)
{
S2 = true;
cout << "\n\n Successfully loaded Image 2" << endl;
}
else
{
return R;
}
}