-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbitwise.cpp
More file actions
47 lines (38 loc) · 1.05 KB
/
Copy pathbitwise.cpp
File metadata and controls
47 lines (38 loc) · 1.05 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
#define cimg_use_png
#include "CImg.h"
using namespace cimg_library;
int main()
{
// Create two images with specified values
CImg<unsigned char> img1(200, 200, 1, 1, 0);
CImg<unsigned char> img2(200, 200, 1, 1, 0);
// Set the first few rows of img1 to 200
for (int y = 0; y < 50; y++)
{
cimg_forX(img1, x)
{
img1(x, y) = 200;
}
}
// Set the first few columns of img2 to 128
for (int x = 0; x < 40; x++)
{
cimg_forY(img2, y)
{
img2(x, y) = 128;
}
}
// Perform the bitwise AND operation
CImg<unsigned char> img_and = img1 & img2;
// Perform the bitwise OR operation
CImg<unsigned char> img_or = img1 | img2;
// Perform the bitwise XOR operation
CImg<unsigned char> img_xor = img1 ^ img2;
// Save the results
img1.save("results/img1.png");
img2.save("results/img2.png");
img_and.save("results/and_image.png");
img_or.save("results/or_image.png");
img_xor.save("results/xor_image.png");
return 0;
}