mirror of
https://github.com/Relintai/MLPP.git
synced 2025-02-08 16:00:04 +01:00
Added gaussian filter, added laplacian filter.
This commit is contained in:
parent
cd0de3bf7c
commit
30737542ed
@ -8,6 +8,7 @@
|
||||
#include "Convolutions/Convolutions.hpp"
|
||||
#include "LinAlg/LinAlg.hpp"
|
||||
#include "Stat/Stat.hpp"
|
||||
#include <cmath>
|
||||
|
||||
namespace MLPP{
|
||||
|
||||
@ -225,6 +226,25 @@ namespace MLPP{
|
||||
return pooledMap;
|
||||
}
|
||||
|
||||
double Convolutions::gaussian2D(double x, double y, double std){
|
||||
double std_sq = std * std;
|
||||
return 1/(2 * M_PI * std_sq) * std::exp(-(x * x + y * y)/2 * std_sq);
|
||||
}
|
||||
|
||||
std::vector<std::vector<double>> Convolutions::gaussianFilter2D(int size, double std){
|
||||
std::vector<std::vector<double>> filter;
|
||||
filter.resize(size);
|
||||
for(int i = 0; i < filter.size(); i++){
|
||||
filter[i].resize(size);
|
||||
}
|
||||
for(int i = 0; i < size; i++){
|
||||
for(int j = 0; j < size; j++){
|
||||
filter[i][j] = gaussian2D(i - (size-1)/2, (size-1)/2 - j, std);
|
||||
}
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
|
||||
std::vector<std::vector<double>> Convolutions::getPrewittHorizontal(){
|
||||
return prewittHorizontal;
|
||||
}
|
||||
|
@ -14,6 +14,9 @@ namespace MLPP{
|
||||
double globalPool(std::vector<std::vector<double>> input, std::string type);
|
||||
std::vector<double> globalPool(std::vector<std::vector<std::vector<double>>> input, std::string type);
|
||||
|
||||
double gaussian2D(double x, double y, double std);
|
||||
std::vector<std::vector<double>> gaussianFilter2D(int size, double std);
|
||||
|
||||
std::vector<std::vector<double>> getPrewittHorizontal();
|
||||
std::vector<std::vector<double>> getPrewittVertical();
|
||||
std::vector<std::vector<double>> getSobelHorizontal();
|
||||
|
Loading…
Reference in New Issue
Block a user