UNPKG

1.21 kBtext/x-cView Raw
1// Copyright 2013 Lovell Fuller and others.
2// SPDX-License-Identifier: Apache-2.0
3
4#ifndef SRC_STATS_H_
5#define SRC_STATS_H_
6
7#include <string>
8#include <napi.h>
9
10#include "./common.h"
11
12struct ChannelStats {
13 // stats per channel
14 int min;
15 int max;
16 double sum;
17 double squaresSum;
18 double mean;
19 double stdev;
20 int minX;
21 int minY;
22 int maxX;
23 int maxY;
24
25 ChannelStats(int minVal, int maxVal, double sumVal, double squaresSumVal,
26 double meanVal, double stdevVal, int minXVal, int minYVal, int maxXVal, int maxYVal):
27 min(minVal), max(maxVal), sum(sumVal), squaresSum(squaresSumVal),
28 mean(meanVal), stdev(stdevVal), minX(minXVal), minY(minYVal), maxX(maxXVal), maxY(maxYVal) {}
29};
30
31struct StatsBaton {
32 // Input
33 sharp::InputDescriptor *input;
34
35 // Output
36 std::vector<ChannelStats> channelStats;
37 bool isOpaque;
38 double entropy;
39 double sharpness;
40 int dominantRed;
41 int dominantGreen;
42 int dominantBlue;
43
44 std::string err;
45
46 StatsBaton():
47 input(nullptr),
48 isOpaque(true),
49 entropy(0.0),
50 sharpness(0.0),
51 dominantRed(0),
52 dominantGreen(0),
53 dominantBlue(0)
54 {}
55};
56
57Napi::Value stats(const Napi::CallbackInfo& info);
58
59#endif // SRC_STATS_H_