This project was conceptualized and realised by Guillaume Fragnière and Killian Viquerat in the context of the DAI class in HEIG-VD.
This program is a small project coded in Java, and it's purpose is to apply some image treatments over a given .bmp
file.
The project supports 4 main features, namely:
The exact usage of the different features will be detailed and explained later in this document.
This project was created with the intent of being usable in the command line. Therefore, we used the picocli framework to do so.
To package the application, we also used Maven for the creation of a .jar
executable file.
We also decided to only be able to apply the filters to .bmp
files for complexity purposes, such as treating the compression in other image format, which can be very tedious and time-consuming.
The writing of the output file is similar in 3 out of the 4 filters, the only special case being the ASCII treatment
. Therefore, we created a class called BMPWriter
in order to write the image in the .bmp
format output file used with the 3 other image treatments, namely PepperReduction
, GrayScale
and Blur
.
Since the ASCII treatment
writes to a text file (.txt
for the gray-scaled and .html
for the colored), we have chosen to write the output file inside the Process
file, resulting in an unpleasing code block. With the implementations we made, we saw it as a good compromise between keeping the other features clean and not being to complex.
To create and organize our workflow, we used a GitHub repository.
In order to properly work on this project, we used a workflow which consisted of:
Since the project consists of 4 different features, each feature was assigned a branch. The CLI integration using picocli was also assigned a specific branch. Note that this integration was heavily inspired by the practical content java-ios
of the DAI class.
Your first step is to clone the project from the repo to your computer
git clone git@github.com:Killian-Viquerat/DAI_Practical_Work_1_Magic_Image_CLI.git
If your using IntelliJ IDEA, the configuration for the packaging of the application will be automatically available inside the IDE. As well as the running one.
The running configuration will just not have parameters precised, so you will need to add them to use the different command available.
For those using only the command line, to package the application you will need to run this command:
mvn dependency:go-offline clean compile package
After packaging the application you can run this command to print the help message:
java -jar ./target/DAI_Practical_Work_1_Magic_Image_CLI-1.0-SNAPSHOT.jar -h
Usage: DAI_Practical_Work_1_Magic_Image_CLI-1.0-SNAPSHOT.jar [-chV] [-s=<size>]
-t=<treatment> <filename> <output> [COMMAND]
A CLI application for the treatment of BMP images
<filename> The input image file name
<output> The output file name
-c, --color Precise the output for the ascii file(used = html file
with colored char | unused = txt file with black and
white char )
-h, --help Show this help message and exit.
-s, --size=<size> The size of the kernel used to average pixel together for
the ascii effect (must be an odd number).
-t, --treatment=<treatment>
The treatment used on the BMP file (possible treatments
being: GrayScale, PepperReduction, ImageToAscii, Blur).
-V, --version Print version information and exit.
This will help in order to compose the different command to test the different feature implemented in the application.
You can refer to the Features described in the Readme:
Each features apply a treatment on the given image using the applyEffect
function inherited by all classes from the Effect
interface.
The gray scale feature is pretty explicit in its usage: it takes the given image and converts it in a gray-scaled version of it. In order to correctly get the color from each pixel of the image, it goes over every pixel, computes the average of the Red/Green/Blue values and sets this value into the pixels color components.
Example of application:
using
java -jar ./target/DAI_Practical_Work_1_Magic_Image_CLI-1.0-SNAPSHOT.jar -t=GrayScale src/images/input/inputColored.bmp src/images/output/outputGrayScaled.bmp bmp_treatment
The pepper reduction feature reduces the pepper noise on a gray-scaled image. In order to force the treatment of a gray-scaled image, we apply the GrayScale
feature first to the input file, no matter if it is gray-scaled or not as a security measure.
This feature works by, in order:
Example of application:
using
java -jar ./target/DAI_Practical_Work_1_Magic_Image_CLI-1.0-SNAPSHOT.jar -t=PepperReduction src/images/input/inputPepper.bmp src/images/output/outputPepper.bmp bmp_treatment
The Image to Ascii feature permit a user to convert an image file to a text file that contain the image as character.
This feature work like this:
Example of application:
First, gray-scaled ASCII:
using
java -jar ./target/DAI_Practical_Work_1_Magic_Image_CLI-1.0-SNAPSHOT.jar -t=ImageToAscii src/images/input/inputPepper.bmp src/images/output/outputAsciiGrayScaled.txt bmp_treatment
Then, colored ASCII:
This feature works the same as the one for the gray-scaled Ascii.
<div style="width: 10px; display: inline-block; color: rgb(170.36,113.36,156.28)">The luminosity char</div>
using
java -jar ./target/DAI_Practical_Work_1_Magic_Image_CLI-1.0-SNAPSHOT.jar -t=ImageToAscii -c src/images/input/inputPepper.bmp src/images/output/outputAsciiColored.html bmp_treatment
The blur feature is exactly what is name is stating, it takes an image and turn it into a blurry image. In order to get the effect of blur we use a kernel called Blur box that we found on wikipedia . It uses image convolution applied to the image to make a new pixel from the 1/9 of all the pixel in the kernel.
Example of application:
using
java -jar ./target/DAI_Practical_Work_1_Magic_Image_CLI-1.0-SNAPSHOT.jar -t=GrayScale src/images/input/inputColored.bmp src/images/output/outputGrayScaled.bmp bmp_treatment
Note that the blurring effect is not very visible on those images because of their high definition and the "low scale" of our kernel for the blurring effect.