This project is about creating a tool that reads an image in a given format (bitmap or jpeg), process this image (enlarge, shrink ...), save the image in an output file different from the one given as input ( same format as input or different) to never corrupt the original files.
Note: This Bitmap Processing tool cannot process:
- Due to RLE compression (Run length encoding)
- bitmap v3
- bitmap v5
- bitmap v7
- Due to bits per pixels < 8
- bitmap v6
- bitmap v7
- bitmap v8
- Digital Image - Bitmap processing tool
- Author
- Introduction
- Table of Contents
- Getting Started
- Feature Implementations
- Feature Descriptions
- Dashboard
- Generate each feature within a test directory
- Display Bitmap header
- Display pixels
- Rotate image
- Resize image
- Contrast adjustment
- Color to grayscale
- Color to black & white (binary)
- Color to negative
- Keep color channel
- Brightness adjustment
- Flip image
- Filter: Edge-detection
- Filter: Edge-reinforcement
- Filter: Blur
- Filter: Emboss
- Color channel Histogram
- Overlay two images
- Image colorization
- Photomaton
- Fun zone
Setup
> git clone https://github.com/Yulypso/Image-Processing-Tool.git
> cd Image-Processing-Tool
> python3 -m venv .venv
# for MacOs/Linux
> source .venv/bin/activate
#for Windows
> py -3 -m venv .venv
> .venv\scripts\activate
# to install requirements
> pip3 install -r requirements.txt
Note: In Visual Studio Code, don't forget to select the correct Python interpreter.
[CMD + SHIFT + P] > select Interpreter > Python 3.9.0 64-bits ('.venv') [./.venv/bin/python]
Run the code
> cd project/bitmapProcessing
> python3 main.py [-h] --bmp <file_name.bmp> [--rotate <rotation degree>]
[--overlay <file_name.bmp>, <option>][--blackwhite]
[--resize <resizing ratio> or [<width> <height>]]
[--verbose] [--flip] [--grayscale <grayscale method>] [--negative]
[--colorchannel <color channel>][--brightness <brightness value>]
[--pixels <all> or [<position x> <position y>]] [--histogram]
[--contrast <contrast value>] [--filter <filter type>]
[--test_features] [--photomaton <split n time>] [--colorize <angle>]
[--output <file_name.bmp>]
--Bitmap processing tool--
optional arguments:
-h, --help show this help message and exit
--bmp <file_name.bmp>
image file to parse and displays header information
--overlay, -ov <file_name.bmp>, <option>
image file to overlay the input image, <maximum> or <minimum>
--rotate, -rt <rotation degree>
degree of image rotation [90, 180, 270]
--resize, -rs <resizing ratio> or [<width> <height>]
ratio of image resizing
--contrast, -ct <contrast value>
image contrast [-255, +255]
--brightness <brightness value>, -bn <brightness value>
image brightness [-255, +255]
--verbose, -v get more information
--flip, -fp image flip
--grayscale, -gs <grayscale method>
image grayscale <mean> or <luminance> or <atget>
--negative, -n image negative
--colorchannel, -cc <color channel>
image color adjustment ['r', 'g', 'b', 'rg', 'rb', 'gb']
--blackwhite, -bw image black & white
--pixels, -p <display option>
display input image pixels <all> or [<position x> <position y>]
--histogram, -hg display input image histogram
--filter, -ft <filter type>
image filter ['edge-detection', 'blur', 'edge-reinforcement', 'emboss']
--photomaton, -ph <split n time>
photomaton, split image by 4 n time
--colorize, -cz <angle>
colorize an image through its hue angle [0°, 360°]
--test_features, -tf generate each feature
--output, -o <file_name.bmp>
generated file
Stop the code
#don't forget to deactivate the virtual environement (.venv)
> deactivate
Unit Test
> cd project/bitmapProcessing
> python3 unitTest.py
....
----------------------------------------------------------------------
Ran 4 tests in 0.000s
OK
To better understand the implementation of those features -> Click here
We will mainly use Colored Lena to explain the features.
Each feature applied on the input bitmap has a checkbox to know easily which feature has been chosen
> python3 main.py --bmp lena_couleur.bmp --rotate 90 -hg -rs 400 400 -fp -ct +80 --pixels all -o generated.bmp -cc rb
> python3 main.py --bmp lena_couleur.bmp --test_features
Display information inside the bitmap byte header
> python3 main.py --bmp lena_couleur.bmp
Display pixel colors at specific position, here x=128 and y=192
> python3 main.py --bmp lena_couleur.bmp --pixels 128 292
Display each bitmap pixel colors, here [ 55 81 158 ] is the first pixel value in the first row and first column of the matrix. (it refers to the real bitmap pixel at the last row and first column)
> python3 main.py --bmp lena_couleur.bmp --pixels all
Rotate the bitmap to 90° or 180° or 270°
> python3 main.py --bmp lena_couleur.bmp --rotate 90 --output generated.bmp --verbose
Resize the bitmap to a ratio value or specific dimensions
- The bitmap has been resized to 256x256 with ratio value=0.5
> python3 main.py --bmp lena_couleur.bmp --resize 0.5 --output generated.bmp --verbose
- The bitmap has been resized to dimension 500x300 (width x height)
> python3 main.py --bmp lena_couleur.bmp --resize 500 300 --output generated.bmp --verbose
Adjust the contrast parameter of the bitmap
> python3 main.py --bmp lena_couleur.bmp --contrast +180 --output generated.bmp --verbose
- Negative adjustment (-255, -180, -80, -0)
- Positive adjustment (+0, +80, +180, +255)
Changes a colored bitmap into a grayscale image
- With Eugène Atget sepia method
> python3 main.py --bmp lena_couleur --grayscale sepia --output generated.bmp --verbose
- With mean method (average)
> python3 main.py --bmp lena_couleur --grayscale mean --output generated.bmp --verbose
- With depending on luminance method (more accurate than mean method)
> python3 main.py --bmp lena_couleur --grayscale luminance --output generated.bmp --verbose
Changes a colored bitmap into a black and white image
> python3 main.py --bmp lena_couleur.bmp --blackwhite --output generated.bmp --verbose
Changes a colored bitmap into a negative image
> python3 main.py --bmp lena_couleur.bmp --negative --output generated.bmp --verbose
Keep one-color or two-color channel of the bitmap
- Red
- Green
- Blue
- Red/Blue (Magenta)
- Red/Green (Yellow)
- Blue/Green (Cyan)
> python3 main.py --bmp lena_couleur.bmp --colorchannel rg --output generated.bmp --verbose
Adjust the brightness parameter of the bitmap
> python3 main.py --bmp lena_couleur.bmp --brightness +80 --output generated.bmp --verbose
- Negative adjustment (-255, -180, -80, -0)
- Positive adjustment (+0, +80, +180, +255)
Flip the bitmap along its vertical axis (along its horizontal axis is the same as a rotation 180°)
> python3 main.py --bmp lena_couleur.bmp --flip --output generated.bmp --verbose
filter to detect the edges of the image
> python3 main.py --bmp lena_couleur.bmp --filter edge-detection --output generated.bmp --verbose
filter to reinforce the edges of the image
> python3 main.py --bmp lena_couleur.bmp --filter edge-reinforcement --output generated.bmp --verbose
filter to blur the image
> python3 main.py --bmp lena_couleur.bmp --filter blur --output generated.bmp --verbose
filter to emboss the image
> python3 main.py --bmp lena_couleur.bmp --filter emboss --output generated.bmp --verbose
Display color channel histogram
> python3 main.py --bmp lena_couleur.bmp --histogram --output generated.bmp --verbose
- Color channel histogram for colored image
- Color channel histogram for grayscale image
Feature to superimpose one image to another
- The output image is generated by obtaining the darkest pixel between the two images
> python3 main.py --bmp lena_couleur.bmp --overlay generated/bitmap512-512.bmp maximum --output generated.bmp --verbose
- The output image is generated by obtaining the lightest pixel between the two images
> python3 main.py --bmp lena_couleur.bmp --overlay generated/bitmap512-512.bmp minimum --output generated.bmp --verbose
Image colorization is mainly used to add color on grayscale images.
> python3 main.py --bmp lena_sepia.bmp --colorize 180 --output generated.bmp --verbose
- Colorization hue angle: 0°/360°, 45°, 90°, 135°
- Colorization hue angle: 180°, 225°, 270°, 315°
The photo booth or Photomaton is used to get several identical images in a whole image
> python3 main.py --bmp lena_sepia.bmp --photomaton 1 --output generated.bmp --verbose