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
|
do {
cout << "Enter E for the Entire Image or P for Part of the image" << endl;
char Option;
cin >> Option;
if (Option == 'P' || Option == 'p')
{
int x = 0;
int y = 0;
int imgheight;
int imgwidth;
cout << "Enter your ROI, The Location(point, x and y axis) You want to work on " << endl;
cout << endl;
cin >> x;
cin >> y;
cout << endl;
if (x >= 0 && x <= img.cols && y >= 0 && y <= img.rows)
{
cout << "Enter the Height and Width of your ROI " << endl;
cout << endl;
cin >> imgheight;
cin >> imgwidth;
imgh = imgh - x;
imgw = imgw - y;
cout << "new-width is :" << imgw << endl;
if (imgheight >= 0 && imgheight <= imgh && imgwidth >=0 && imgwidth <= imgw)
{
cout << " Enter From 0 to 9 The Intercity Of The Blur You Want " << endl;
cout << endl;
int Ksize1, Ksize2;
cin >> Ksize1;
cin >> Ksize2;
if (Ksize1 >= 1 && Ksize1 <= 35 && Ksize2 >= 1 && Ksize2 <= 35)
{
Rect rect(x, y, imgheight, imgwidth);
GaussianBlur(img, des, Size(Ksize1, Ksize2), 0);
string ImageO = "Original Image";
string ImageB = "GaussianBlured";
namedWindow(ImageO);
namedWindow(ImageB);
imshow(ImageO, img);
waitKey(0);
imshow(ImageB, des), waitKey(0);
}
}
}
}
else if (Option == 'E' || Option == 'e')
{
auto x = 0;
auto y = 0;
int imgheight = img.cols;
int imgwidth = img.rows;
cout << " Enter From 0 to 9 The Intercity Of The Blur You Want " << endl;
cout << endl;
int Ksize1, Ksize2;
cin >> Ksize1;
cin >> Ksize2;
if (Ksize1 >= 1 && Ksize1 <= 35 && Ksize2 >= 1 && Ksize2 <= 35)
{
Rect rect(x, y, imgheight, imgwidth);
GaussianBlur(img, des, Size(Ksize1, Ksize2), 0);
string ImageO = "Original Image";
string ImageB = "GaussianBlured";
namedWindow(ImageO);
namedWindow(ImageB);
imshow(ImageO, img);
waitKey(0);
imshow(ImageB, des), waitKey(0);
}
}
} while (true, cout<<"Try Again"<<endl);
| |