Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_histogram.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2004 Boudewijn Rempt
3 * SPDX-FileCopyrightText: 2005 Bart Coppens <kde@bartcoppens.be>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7#ifndef KIS_HISTOGRAM_
8#define KIS_HISTOGRAM_
9
10#include <QVector>
11#include <QRect>
12
13#include "KoHistogramProducer.h"
14
15#include "kis_shared.h"
16#include "kis_types.h"
17#include "kritaimage_export.h"
18
36class KRITAIMAGE_EXPORT KisHistogram : public KisShared
37{
38
39public:
45 {
46
47 double m_max {0.0};
48 double m_min {0.0};
49 double m_mean {0.0};
50 double m_total {0.0};
51
52 quint32 m_high {0};
53 quint32 m_low {0};
54 quint32 m_count {0};
55
56 friend class KisHistogram;
57
58 public:
59
61 {
62 }
67 inline double getMax() {
68 return m_max;
69 }
74 inline double getMin() {
75 return m_min;
76 }
78 inline quint32 getHighest() {
79 return m_high;
80 }
82 inline quint32 getLowest() {
83 return m_low;
84 }
86 inline double getMean() {
87 return m_mean;
88 }
89 //double getMedian() { return m_median; }
90 //double getStandardDeviation() { return m_stddev; }
92 inline quint32 getCount() {
93 return m_count;
94 }
96 inline double getTotal() {
97 return m_total;
98 }
99 //quint8 getPercentile() { return m_percentile; } // What is this exactly? XXX
100 };
101
103 KoHistogramProducer *producer,
104 const enumHistogramType type);
105
107 const QRect &bounds,
108 KoHistogramProducer *producer,
109 const enumHistogramType type);
110
111 virtual ~KisHistogram();
112
114 void updateHistogram();
115
120 void computeHistogram();
121
123 Calculations calculations();
125 Calculations selectionCalculations();
126
127 inline quint32 getValue(quint8 i) {
128 return m_producer->getBinAt(m_channel, i);
129 }
130
132 return m_type;
133 }
135 m_type = type;
136 }
137 inline void setProducer(KoHistogramProducer *producer) {
138 m_channel = 0;
139 m_producer = producer;
140 }
141 inline void setChannel(qint32 channel) {
142 Q_ASSERT(m_channel < m_completeCalculations.size());
143 m_channel = channel;
144 }
146 return m_producer;
147 }
148 inline qint32 channel() {
149 return m_channel;
150 }
151
152 inline bool hasSelection() {
153 return m_selection;
154 }
155 inline double selectionFrom() {
156 return m_selFrom;
157 }
158 inline double selectionTo() {
159 return m_selTo;
160 }
161 inline void setNoSelection() {
162 m_selection = false;
163 }
165 inline void setSelection(double from, double to) {
166 m_selection = true; m_selFrom = from; m_selTo = to;
167 }
168
169
170private:
171 // Dump the histogram to debug.
172 void dump();
173 QVector<Calculations> calculateForRange(double from, double to);
174 Calculations calculateSingleRange(int channel, double from, double to);
175
177 QRect m_bounds;
178 KoHistogramProducer *m_producer {nullptr};
180
181 qint32 m_channel {0};
182 double m_selFrom {0.0};
183 double m_selTo {0.0};
184 bool m_selection {false};
185
187};
188
189
190#endif // KIS_HISTOGRAM_WIDGET_
double getMean()
This function return the mean of value of the histogram.
quint32 getCount()
This function return the number of pixels used by the histogram.
quint32 getHighest()
This function return the highest value of the histogram.
quint32 getLowest()
This function return the lowest value of the histogram.
void setChannel(qint32 channel)
quint32 getValue(quint8 i)
double selectionFrom()
void setHistogramType(enumHistogramType type)
KoHistogramProducer * producer()
QVector< Calculations > m_completeCalculations
qint32 channel()
const KisPaintDeviceSP m_paintDevice
void setSelection(double from, double to)
bool hasSelection()
void setNoSelection()
enumHistogramType getHistogramType()
double selectionTo()
void setProducer(KoHistogramProducer *producer)
#define bounds(x, a, b)
enumHistogramType
@ LOGARITHMIC
@ LINEAR
@ LINEAR
Definition nugrid.h:26