Реализация фильтров
This commit is contained in:
parent
24e2cbb354
commit
3fe2a87e35
4 changed files with 109 additions and 58 deletions
22
bmpimage.h
22
bmpimage.h
|
@ -3,9 +3,17 @@
|
|||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include "psf.h"
|
||||
|
||||
const char PADDING_ZEROES[3] = {0, 0, 0};
|
||||
const int AVERAGE_MASK[9] = {1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
const int PREWITT_MASK_DX[9] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
|
||||
const int PREWITT_MASK_DY[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
|
||||
const int SOBEL_MASK_DX[9] = {-1, 0, 1, -2, 0, 2, -1, 0, 1};
|
||||
const int SOBEL_MASK_DY[9] = {-1, -2, -1, 0, 0, 0, 1, 2, 1};
|
||||
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct BitmapFileHeader {
|
||||
|
@ -91,6 +99,8 @@ public:
|
|||
BMPImage appendRight(BMPImage &);
|
||||
|
||||
BMPImage overlay(BMPImage &, uint32_t, uint32_t);
|
||||
|
||||
BMPImage applyFilter(const std::function<uint8_t (std::array<int,9>&)>& filter);
|
||||
};
|
||||
|
||||
BMPImage readBMPImage(const std::string &filename);
|
||||
|
@ -126,4 +136,14 @@ BMPImage textImg(const std::u16string &, Font *font, uint8_t scale = 1, Pixel ba
|
|||
|
||||
uint8_t ui8_clamp(int value, uint8_t min = 0, uint8_t max = 255);
|
||||
|
||||
BMPImage filter(BMPImage &img, int mask[9], uint8_t modifier = 9);
|
||||
uint8_t medianFilter(std::array<int, 9> &);
|
||||
|
||||
uint8_t averageFilter(std::array<int, 9> &);
|
||||
|
||||
uint8_t prewittDXFilter(std::array<int, 9> &);
|
||||
|
||||
uint8_t prewittDYFilter(std::array<int, 9> &);
|
||||
|
||||
uint8_t sobelDXFilter(std::array<int, 9> &);
|
||||
|
||||
uint8_t sobelDYFilter(std::array<int, 9> &);
|
Loading…
Add table
Add a link
Reference in a new issue