Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.
/ bitmap-editor Public archive

Edit bitmaps. While studying linear algebra and some simple image processing, I wrote this small CLI in pure C to practice the theory.

Notifications You must be signed in to change notification settings

larapollehn/bitmap-editor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bitmap Editor

This simple bitmap editor is the product of my adventure of diving into the world of bitmap images, image processing and linear algebra.


Editor Features

After compiling the project with gcc the bitmap-editor can be used over the command line. See below for the help page listing all available features with sample commands.

General info: most features work for 24bpp bitmap images only.

lara@larapollehn:~/CodingProjects/bitmap-editor/cmake-build-debug$ ./lib help
usage: ./lib

The following are common commands:

get an overview of the bitmap infos (like headers)
   info          ./lib [info|-i] <src-file>
                 e.g.: './lib info lena.bmp'

make a copy of an bitmap image
   copy          ./lib [copy|-cp] <src-file> <dest-file>
                 e.g.: './lib copy lena.bmp lena_copy.bmp'

grayscale an image (naive (r+g+b)/3 )
   grayscale     ./lib [grayscale|-gs] <src-file> <dest-file>
                 e.g.: './lib grayscale lena.bmp lena_gray.bmp'

create 24bpp images and draw geometric shapes on them
   create        ./lib [create|-c] [width:|w:] int [height:/h:] int [color:/c:] int(r) int(g) int(b) <dest-file>
                 e.g.: './lib create w: 200 h: 200 c: 241 136 201 pink_panther.bmp'

   draw-circle   ./lib [draw|-d] [circle|-c] [radius:|r:] int [origin:/o:] int(x) int(y) [color:/c:] int(r) int(g) int(b) <dest-file>
                 e.g.: './lib draw circle r: 100 o: 50 75 c: 247 255 173 pink_panther.bmp'

   draw-rect     ./lib [draw|-d] [rectangle|-r] [pointE:/e:] int(x) int(y) [pointF:/f:] int(x) int(y) [pointG:/g:] int(x) int(y) [pointH:/h:] int(x) int(y) [color:/c:] int(r) int(g) int(b) <dest-file>
                 e.g.: './lib draw rectangle e: 50 50 f: 50 100 g: 100 100 h: 100 50 c: 71 167 255 pink_panther.bmp'

   draw-tri      ./lib [draw|-d] [triangle|-t] [pointE:/e:] int(x) int(y) [pointF:/f:] int(x) int(y) [pointG:/g:] int(x) int(y) [color:/c:] int(r) int(g) int(b) <dest-file>
                 e.g.: './lib draw triangle e: 50 150 f: 20 300 g: 300 300 c: 16 95 74 pink_panther.bmp'

simple image processing using image convolution and an 3x3 kernel
   convolution   ./lib [convolution|-cv] [kernel:|k:] int int int int int int int int int [divider:|d:] int <src-file> <dest-file>
                 e.g.: './lib convolution k: 1 0 -1 0 0 0 -1 0 1 d: 1 lena.bmp lena_edge_detect.bmp'

Grayscale

A naive interpretation to grayscale an image with 3 color channels (red, green, blue). The gray shade is computed by adding the RGB color channel values and dividing the sum by three. Alpha Channels are not included.

Before
After
before-grayscale after-grayscale
before-grayscale after-grayscale

Create and Draw

A completely new bitmap image can be created and as many (or none) triangles, rectangles and circles can be drawn onto it. The resulting image does not index the pixel colors, instead uses 3 Bytes (one for each of the three color channels) to store the colors directly in the image data (pixels).

Create create
Draw Circle draw-circle
Draw Rectangle draw-rectangle
Draw Triangle draw-triangle

Convolution

With the use of a 3x3 kernel and the belonging divider the original bitmap image is convolved. Edge Handling: Crop (all the edge pixels are untouched)

1. Edge Detection (different kernels)
Before
After
edge-before edge-after
edge-before edge-after
2. Blur (Box Blur & Gaussian Blur)
Before
After
edge-before edge-after
edge-before edge-after
3. Sharpen
Before
After
edge-before edge-after
edge-before edge-after

Bitmap Images:

The bitmap image file is a 2D raster graphic storing an image (digital) with varying options regarding the bitmap data and color channels.

The binary file of an bitmap image stores two kinds of headers, an optional color table for indexed bitmap data and the actual bitmap data representing the individual pixels of the image.

Image processing

With the help of a kernel, also known as convolution matrix or mask, the original image data (pixels) will be convolved to accomplish a wide range of effects like the Gaussian blur, edge detection or sharpening.

Linear Algebra

In order to draw geometric shapes into a bitmap image several topics of linear algebra were needed to for example correctly determine if a pixel lies within a triangle/square/circle shape.

Topics included: matrices and vectors, pythagorean theorem, scalar product (dot-product), barycentric weights


References

About

Edit bitmaps. While studying linear algebra and some simple image processing, I wrote this small CLI in pure C to practice the theory.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published