Primo commit di questa repo, è un bel progettino molto semplice da funzioni esplicative
This commit is contained in:
40
libImg.h
Normal file
40
libImg.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <vector>
|
||||
#include <random>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
struct pixel {
|
||||
unsigned char r, g, b;
|
||||
|
||||
bool operator==(const pixel& o) const { return r == o.r && g == o.g && b == o.b; }
|
||||
bool operator!=(const pixel& o) const { return !(*this == o); }
|
||||
bool operator>=(const pixel& o) const { return r - o.r + g - o.g + b - o.b > 0; }
|
||||
|
||||
float lum() const { return 0.2126f * r + 0.7152f * g + 0.0722f * b; }
|
||||
float lumNorm() const { return lum() / 255.0f; }
|
||||
};
|
||||
|
||||
using image = std::vector<std::vector<pixel>>;
|
||||
|
||||
//Variabili importanti
|
||||
inline std::mt19937 rng(10);
|
||||
inline std::uniform_int_distribution<unsigned int> dist(0, 255);
|
||||
inline image errore(1, std::vector<pixel>(1, {0, 0, 0}));
|
||||
|
||||
|
||||
bool save(const std::string& path, const image& matrix);
|
||||
image load(const std::string& path, int& w, int& h);
|
||||
|
||||
bool images_equal(const image& a, const image& b);
|
||||
unsigned long long countW(image &matrix);
|
||||
|
||||
image randomImage(int w, int h);
|
||||
void BWimage(image &matrix, float lim);
|
||||
void Grayimage(image &matrix);
|
||||
float BWAimage(image &matrix);
|
||||
void invertImage(image &matrix);
|
||||
void gaussianImage(image &matrix, int dim);
|
||||
Reference in New Issue
Block a user