|
1 | | -# BMP Image Processing Lab |
2 | | - |
3 | | -**Author:** Gleb Shikunov |
4 | | -**Student ID:** st128274@student.spbu.ru |
5 | | -**Course:** Programming in C++ |
6 | | -**Lab:** #1 - Loading and Processing Raster Images |
7 | | - |
| 1 | +# Lab 1 |
| 2 | +## Author |
| 3 | +Шикунов Глеб Александрович, группа 24.Б81-мм |
| 4 | +## Contacts |
| 5 | +st128274@student.spbu.ru |
8 | 6 | ## Description |
9 | | - |
10 | | -This project implements a BMP image processing application that performs the following operations: |
11 | | - |
12 | | -1. **Load BMP images** - Supports 24-bit and 32-bit color BMP files |
13 | | -2. **Rotate images** - 90° clockwise and counter-clockwise rotation |
14 | | -3. **Apply Gaussian filter** - Smoothing filter for image processing |
15 | | -4. **Save processed images** - Output in BMP format |
16 | | - |
17 | | -## Features |
18 | | - |
19 | | -- ✅ Memory efficient processing (uses ~100% of data size) |
20 | | -- ✅ Real-time performance (total processing < 15ms) |
21 | | -- ✅ No memory leaks (RAII design) |
22 | | -- ✅ Comprehensive error handling |
23 | | -- ✅ Detailed timing and memory usage reporting |
24 | | -- ✅ Support for both 24-bit and 32-bit BMP files |
25 | | - |
26 | | -## Project Structure |
27 | | - |
28 | | -``` |
29 | | -lab1/ |
30 | | -├── main.cpp # Main application logic |
31 | | -├── WorkWithBMP.h # BMP processing class header |
32 | | -├── WorkWithBMP.cpp # BMP processing class implementation |
33 | | -├── Makefile # Build configuration |
34 | | -├── README.md # This file |
35 | | -└── *.bmp # Sample images and outputs |
36 | | -``` |
37 | | - |
38 | | -## Build Instructions |
39 | | - |
40 | | -### Prerequisites |
41 | | -- C++17 compatible compiler (GCC, Clang, MSVC) |
42 | | -- Make utility |
43 | | - |
44 | | -### Compilation |
| 7 | +Lab1 |
| 8 | +## Build |
45 | 9 | ```bash |
46 | | -# Build the project |
47 | 10 | make |
48 | | - |
49 | | -# Build and run |
50 | | -make run |
51 | | - |
52 | | -# Clean build artifacts |
53 | | -make clean |
54 | | - |
55 | | -# Debug build |
56 | | -make debug |
57 | | - |
58 | | -# Release build |
59 | | -make release |
60 | 11 | ``` |
61 | | - |
62 | | -## Usage |
63 | | - |
| 12 | +## Clean images |
64 | 13 | ```bash |
65 | | -# Run the program |
66 | | -./bmp_processor |
67 | | -``` |
68 | | - |
69 | | -The program will: |
70 | | -1. Load the sample image `1718889054_sample_640×426.bmp` |
71 | | -2. Create rotated versions (clockwise and counter-clockwise) |
72 | | -3. Apply Gaussian filter to both rotated versions |
73 | | -4. Save all results as new BMP files |
74 | | - |
75 | | -## Output Files |
76 | | - |
77 | | -- `Mandrill_rotated_clockwise.bmp` - Image rotated 90° clockwise |
78 | | -- `Mandrill_rotated_counter_clockwise.bmp` - Image rotated 90° counter-clockwise |
79 | | -- `Mandrill_filtered_clockwise.bmp` - Clockwise rotated image with Gaussian filter |
80 | | -- `Mandrill_filtered_counter_clockwise.bmp` - Counter-clockwise rotated image with Gaussian filter |
81 | | - |
82 | | -## Technical Details |
83 | | - |
84 | | -### BMP Format Support |
85 | | -- File header parsing (14 bytes) |
86 | | -- Information header parsing (40 bytes) |
87 | | -- Support for 24-bit and 32-bit color depth |
88 | | -- Proper row padding handling (4-byte alignment) |
89 | | - |
90 | | -### Memory Management |
91 | | -- RAII (Resource Acquisition Is Initialization) design |
92 | | -- Automatic memory cleanup |
93 | | -- Memory usage tracking and reporting |
94 | | -- Efficient data structures |
95 | | - |
96 | | -### Performance |
97 | | -- Optimized rotation algorithms |
98 | | -- Efficient Gaussian filter implementation |
99 | | -- Minimal memory allocations |
100 | | -- Real-time processing capabilities |
101 | | - |
102 | | -## Algorithm Details |
103 | | - |
104 | | -### Image Rotation |
105 | | -- **Clockwise**: `(x, y) → (height - 1 - y, x)` |
106 | | -- **Counter-clockwise**: `(x, y) → (y, width - 1 - x)` |
107 | | -- Proper handling of row padding after rotation |
108 | | - |
109 | | -### Gaussian Filter |
110 | | -3x3 kernel with coefficients: |
111 | | -``` |
112 | | -[1/16 2/16 1/16] |
113 | | -[2/16 4/16 2/16] |
114 | | -[1/16 2/16 1/16] |
115 | | -``` |
116 | | - |
117 | | -## Error Handling |
118 | | - |
119 | | -The application includes comprehensive error handling for: |
120 | | -- File I/O operations |
121 | | -- Invalid BMP format |
122 | | -- Memory allocation failures |
123 | | -- Data size mismatches |
124 | | -- Unsupported image formats |
125 | | - |
126 | | -## Performance Metrics |
127 | | - |
128 | | -For the sample image (640×426, 24-bit): |
129 | | -- **Load time**: ~1ms |
130 | | -- **Rotation time**: ~1ms each direction |
131 | | -- **Filter time**: ~2ms each |
132 | | -- **Total processing time**: ~14ms |
133 | | -- **Memory usage**: 100.013% of data size |
134 | | -- **Memory efficiency**: ✓ Within 200% limit |
135 | | - |
136 | | -## Testing |
137 | | - |
138 | | -The program has been tested with: |
139 | | -- Various BMP file sizes |
140 | | -- Different color depths (24-bit, 32-bit) |
141 | | -- Memory leak detection (valgrind) |
142 | | -- Performance benchmarking |
143 | | - |
144 | | -## License |
145 | | - |
146 | | -This project is part of academic coursework and follows university guidelines. |
| 14 | +make distclean |
| 15 | +``` |
0 commit comments