HIPHOP (Handy Image Processing for Highly Over-caffeinated Programmers), a domain specific language for image processing.
HIPHOP is built with Python3, along with multiple modules. To install these, perform the following steps:
pip3 install opencv-python
pip3 install termcolor
pip3 install colorama
pip3 install numpy
HIPHOP can be used in two ways: command line mode and running a HIPHOP script
(may have to use python3 instead of python depending on which platform you are on)
Command line mode that reads in line by line:
python main.py
Running script written in HIPHOP:
python main.py <location of script>
<HHE> ::= open <filename> as <id>
| save <id> as <filename>
| apply <func> to <id>
| apply-all [<funcs>] to <id>
| save-macro [<funcs>] as <id>
<filename> ::= "<literal>"
<funcs> ::= <func>
| <func>, <funcs>
<func> ::= <id> <nums>
<literal> ::= STRING
<nums> ::=
| <num> <nums>
open "testing/images/test-color.jpg" as test-img
reload test-img
save test-img as "testing/output/result.jpg"
wd
save test-img as "genfilename" jpg
apply blur 10 to test-img
apply-all [grayscale, blur 10] to test-img
save-macro [blur 10, grayscale] to blurscale
apply blurscale to img1
apply blurscale to img2
wd
as working directory, all
as all variables
set wd "testing/images/"
open "test-img.jpg" as test
get wd
get all
Function Name | Number of Arguments | Argument Names | What The Function Does | Example Usage |
---|---|---|---|---|
blur | 1 | scale | Blurs the image by averaging the image with a kernel of scale*scale size | blur 10 |
grayscale | 0 | n/a | Turns the image into black and white | grayscale |
erode | 1 | scale | Erodes the image with a kernel of scale*scale size with full of ones | erode 3 |
dilate | 1 | scale | Dilates the image with a kernel of scale*scale size with full of ones | dilate 3 |
outline | 1 | scale | Removes the noise in image by eroding and dilating the image with a kernel of scale*scale size with full of ones | outline 5 |
filtercolor | 6 | lowR, lowG, lowB, highR, highG, highB | Filters the image so only color between [lowB, lowG, lowR] and [highB, highG, highR] returns and turns rest of image black | filtercolor 50 50 110 255 255 130 |
scale | 2 | x, y | Scales the image to x*original width and y*original height | scale 0.5 0.3 |
impose | 3 | overlayImage, px, py | Overlays an opened image over another opened image at the specified pixel value of the background image. The overlay images top left corner will end up at that coordinate. | impose imageId 15 25 |
crop | 4 | widthlow, widthhigh, heightlow, heighthigh | Crops the image with specified range, where the range of image is [-1, 1] for width and height with 0 at center Applying example on the right on an image with width 200 and height 100 would return a new image with pixels width ranged [50, 150] and height ranged [25, 75] of original image |
crop -0.5 0.5 -0.5 0.5 |
wave | 2 | direction, amplitude | Applies a sine wave to the image vertically (v), horizontallity (h), or multidirectionally (m). | wave h 35 |