Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Commit 6e28284

Browse files
committed
convolve finished!
1 parent 1f906ae commit 6e28284

17 files changed

+119
-42
lines changed

README.md

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# cpsc4040-GLOIIO project3
1+
# cpsc4040-GLOIIO project4 (v0.4)
22
#### OpenGL/GLUT Program Suite to read, display, modify, and write images using the OpenImageIO API
3-
Dr. Karamouzas "Green screening"
3+
Dr. Karamouzas "Convolution"
44

55
by Owen Book ([email protected])
66

@@ -9,13 +9,13 @@ by Owen Book ([email protected])
99
### Compilation
1010
Makefile is included. You can run these commands:
1111

12-
`make project3` or `make`: compile only alphamask and compose
12+
`make`: clean compiled outputs and compile only `convolve`
1313

1414
`make all`: compile all code into the program suite
1515

1616
`make recompile`: clean compiled outputs and recompile all code into the program suite
1717

18-
`make [imgview, alphamask, compose]`: compile just one program at a time
18+
`make [imgview, alphamask, compose, convolve]`: compile just one program at a time
1919

2020
`make clean`: delete compiled outputs (will not touch images the program creates)
2121

@@ -64,14 +64,7 @@ If the input file does not exist or cannot be opened, the program will exit.
6464

6565
If .png is omitted from output, the program will append it automatically. You cannot print any other image format from this program - convert it with other software.
6666

67-
If not enough values are provided for target or fuzz, the program will ignore the rest. (It's not particularly helpful but at least you can see a result - a .cfg file was planned but trying to user-proof it was a nightmare)
68-
69-
#### My inputs for masking each image
70-
D.House: 135.0 0.7 0.4 60.0 0.5 0.5 - there's a cloud of low alpha pixels to the left, but it's not a big issue
71-
72-
Hand: 90.0 0.5 0.5 40.0 0.6 0.6 - this one looks pretty clean!
73-
74-
Scientist: 130.0 0.7 0.6 40.0 0.7 0.6 - best I could get without wrecking parts of the image
67+
If not enough values are provided for target or fuzz, the program will ignore the rest. (It's not particularly helpful but at least you can see a result - a .cfg file was planned but trying to user-proof it is a nightmare)
7568

7669
## compose
7770
**compose** draws one image over another, taking transparency into account. It does not support cropping - the background image *B* must be the same size as or larger than the foreground image *A*.
@@ -92,3 +85,43 @@ Load the foreground image A and background image B using their file paths. You c
9285
If either input file does not exist or cannot be opened, the program will exit.
9386

9487
If the file extension is omitted from output, the program will assume .png format.
88+
89+
## convolve
90+
**convolve** allows you to apply simple global filters (.filt) to an image as many times as desired.
91+
92+
#### Controls
93+
The program will automatically display the original image.
94+
95+
C: apply filter once
96+
97+
R: revert to original image (specifically, deletes the displayed data and copies the original data)
98+
99+
W: write result to file (prompts if not specified in command line)
100+
101+
Q or ESC: quit program
102+
103+
Note that applying filters will take some time depending on the image and filter sizes. It's not recommended to use large images with this program at the moment.
104+
105+
106+
#### Command line usage
107+
Load the desired filter file first, then the image you want to open. Additionally, you can specify your desired output filename from the command line instead of entering it upon pressing W.
108+
109+
```./convolve [filter].filt [image] (output)```
110+
111+
If either input file or filter file do not exist or cannot be opened, the program will exit. This specific program was designed for .png images foremost, but should theoretically work with most common formats.
112+
113+
114+
#### .filt format
115+
**.filt** files are plaintext data files that define a global convolution filter. Only numbers (integer or floating point, anything's fine) should be put inside each file - any non-numerical data may cause errors.
116+
117+
The first number in the file, designated *N*, informs the program of the size of the filter kernel, or its number of rows and columns. The program expects *N*^2 entries after that, separated by whitespace. The exact line usage does not matter, but keeping each row of the filter kernel seperate is recommended.
118+
119+
You can find various examples in the included `filters` directory.
120+
121+
122+
#### Known issues
123+
convolve currently copies the original pixel value to calculate values for pixels that would be outside the image. This may cause edges of images to be bizzarely colored or not change.
124+
125+
Additionally, the program currently uses a scale factor and clamping function to keep resulting values within 8 bits per channel. The original plan was to normalize the kernel when loading it, but I discarded this behavior during some confusion with calculations. The current method can make areas of some images too dark or too bright, especially if relatively large negative values are in the filter kernel.
126+
127+
Edge calculation filters in general do not work too well with this version of the program.

filters/encrust7.filt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
7
2+
0.2 1 3 -4 3 1 0.2
3+
0 3 -3 0 3 -3 0
4+
1 2 3 4 3 2 1
5+
-7 2 0 0 0 -2 7
6+
4 3 2 1 2 3 4
7+
0 -3 3 0 -3 3 0
8+
0.2 1 3 -4 3 1 0.2

filters/pinhole3.filt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
1 1 1
3+
1 0 1
4+
1 1 1

filters/sharpener5.filt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
5
2+
0 0 -1 0 0
3+
0 -1 -2 -1 0
4+
-1 -2 17 -2 -1
5+
0 -1 -2 -1 0
6+
0 0 -1 0 0

filters/test.filt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
0 0 0
3+
0 1 0
4+
0 0 0

results/backgrounds/blankbg.png

-2.54 KB
Binary file not shown.

results/backgrounds/busy.png

-226 KB
Binary file not shown.

results/backgrounds/mistbg.png

-274 KB
Binary file not shown.

results/backgrounds/sunbaby.png

-351 KB
Binary file not shown.

results/dhouse_compose.png

-571 KB
Binary file not shown.

0 commit comments

Comments
 (0)