A basic command-line image processing script for bitmap images written from scratch in C.
- Supports
BMP v3,BMP v4andBMP v5. - Supports
24-bitand32-bitbitmap images. - Does not support color palettes.
- Does not support compression.
./transform [options] <input file> <output file>-
-iInvert colors of image.
./transform sampleImages/marbles.bmp invert.bmp -i
Original Inverted 

-
-l <factor>Apply log gamma transform (natural log) with a multiplication
<factor>../transform sampleImages/lightLarge.bmp log.bmp -l 30
Original Log Gamma 

-
-e <factor>Apply inverse log gamma transform (natural log) with a multiplication
<factor>../transform sampleImages/lightLarge.bmp inverseLog.bmp -e 0.001
Original Inverse Log Gamma 

-
-p <gamma>Apply power-law gamma transform - RGB intensities are raised to the power
(1 / <gamma>)../transform sampleImages/harvard.bmp gamma.bmp -p 2.0
Original Power-Law Gamma 

To apply the inverse gamma transform use
(1 / original gamma)as<gamma>value../transform sampleImages/harvard.bmp inverseGamma.bmp -p 0.5
Original Inverse Power-Law Gamma 

Example: To get inverse of
<gamma> = 2.0set<gamma> = 0.5./transform sampleImages/harvard.bmp gamma.bmp -p 2.0 ./transform gamma.bmp retrieve.bmp -p 0.5
Original Power-Law Gamma Inverse of Power-Law Gamma 


Note: We have significant banding or loss of data in the highlights as the original image's hightights were already blown out.
We can also do this in a single step:
./transform sampleImages/lightLarge.bmp retrieveLight.bmp -p 2.0 -p 0.5
Original Retrieved 

-
-gConvert image to
8-bitgreyscale image.Note: Any options provided after this will be discarded.
./transform sampleImages/cat.bmp grey.bmp -g
Original Greyscale 

-
-bBit plane slicing:
Convert image to greyscale and generate 8
1-bitmonochrome images representing each bit plane ranging from MSB (Most Significant Bit) to LSB (Least Significant Bit) - Bit numbering.Note: Any options provided after this will be discarded.
./transform sampleImages/lightLarge.bmp out.bmp -b
Original Greyscale 

BitPlane 0 BitPlane 1 BitPlane 2 BitPlane 3 



BitPlane 4 BitPlane 5 BitPlane 6 BitPlane 7 



-
-s[=ATTR_LIST]Set a range of RGB intensities to specified intensity.
Attributes:
"Ra, Rb, Ri, Ga, Gb, Gi, Ba, Bb, Bi"Intensities
atobare set to intensityi../transform sampleImages/harvard.bmp intensities.out -s150,255,255,50,100,100,200,255,200
Original Intensities 

The order in which the options are provided are the order in which the transforms are applied.