-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvst.cpp
More file actions
40 lines (32 loc) · 956 Bytes
/
vst.cpp
File metadata and controls
40 lines (32 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// Created by Nicola Pierazzo on 03/02/16.
//
#include <iostream>
#include <cmath>
#include <algorithm>
#include "Image.hpp"
#include "utils.hpp"
using namespace imgutils;
using std::string;
using std::cerr;
using std::endl;
using std::max;
int main(int argc, char *argv[]) {
bool usage = pick_option(&argc, argv, "h", nullptr);
bool inverse = pick_option(&argc, argv, "i", nullptr);
if (usage || argc < 3) {
cerr << "usage: " << argv[0] << " a b [-i] [input [output]]" << endl;
cerr << "Applies the (inverse) VST when the image has the noise model sqrt(ax + b)" << endl;
return EXIT_SUCCESS;
}
float a = atof(argv[1]);
float b = atof(argv[2]);
Image im = read_image(argc > 3 ? argv[3] : "-");
if (inverse) {
for (float& x : im) x = (a / 4.f) * x * x - (b / a);
} else {
for (float& x : im) x = (2.f / a) * sqrt(max(0.f, a * x + b));
}
save_image(im, argc > 4 ? argv[4] : "-");
return EXIT_SUCCESS;
}