Add H-S and H-C vectorscopes

This commit is contained in:
Lawrence Lee
2020-08-03 18:23:25 -07:00
parent 6df69b3786
commit fbe73614c3
8 changed files with 299 additions and 22 deletions

View File

@@ -1643,6 +1643,9 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
if (hListener->updateHistogram()) {
updateLRGBHistograms();
}
if (hListener->updateVectorscope()) {
updateVectorscope();
}
if (hListener->updateWaveform()) {
updateWaveforms();
}
@@ -1765,6 +1768,8 @@ void ImProcCoordinator::notifyHistogramChanged()
histBlueRaw,
histChroma,
histLRETI,
vectorscopeScale,
vectorscope,
waveformScale,
waveformWidth,
waveformRed.get(),
@@ -1835,6 +1840,55 @@ void ImProcCoordinator::updateLRGBHistograms()
}
void ImProcCoordinator::updateVectorscope()
{
if (!workimg) {
return;
}
int x1, y1, x2, y2;
params->crop.mapToResized(pW, pH, scale, x1, x2, y1, y2);
constexpr int size = HistogramListener::vectorscope_size;
memset(vectorscope, 0, size * size * sizeof(vectorscope[0][0]));
for (int i = y1; i < y2; i++) {
int ofs = (i * pW + x1) * 3;
for (int j = x1; j < x2; j++) {
switch (hListener->vectorscopeType()) {
case 0: {
// HS
int r = 256 * workimg->data[ofs++];
int g = 256 * workimg->data[ofs++];
int b = 256 * workimg->data[ofs++];
float h, s, l;
Color::rgb2hsl(r, g, b, h, s, l);
const int col = s * cos(2 * RT_PI * h) * (size / 2) + size / 2;
const int row = s * sin(2 * RT_PI * h) * (size / 2) + size / 2;
if (col >= 0 && col < size && row >= 0 && row < size) {
vectorscope[row][col]++;
}
break;
}
case 1: {
// CH
const int col = (size / 96000.0) * nprevl->a[i][j] + size / 2;
const int row = (size / 96000.0) * nprevl->b[i][j] + size / 2;
if (col >= 0 && col < size && row >= 0 && row < size) {
vectorscope[row][col]++;
}
break;
}
}
}
}
vectorscopeScale = workimg->getWidth() * workimg->getHeight();
}
void ImProcCoordinator::updateWaveforms()
{
if (!workimg) {
@@ -2314,7 +2368,7 @@ void ImProcCoordinator::setHighQualComputed()
highQualityComputed = true;
}
void ImProcCoordinator::updateWaveform()
void ImProcCoordinator::requestUpdateWaveform()
{
if (hListener) {
updateWaveforms();
@@ -2322,7 +2376,7 @@ void ImProcCoordinator::updateWaveform()
}
}
void ImProcCoordinator::updateHistogram()
void ImProcCoordinator::requestUpdateHistogram()
{
if (hListener) {
updateLRGBHistograms();
@@ -2330,4 +2384,12 @@ void ImProcCoordinator::updateHistogram()
}
}
void ImProcCoordinator::requestUpdateVectorscope()
{
if (hListener) {
updateVectorscope();
notifyHistogramChanged();
}
}
}

View File

@@ -126,6 +126,8 @@ protected:
LUTu histBlue, histBlueRaw;
LUTu histLuma, histToneCurve, histToneCurveBW, histLCurve, histCCurve;
LUTu histLLCurve, histLCAM, histCCAM, histClad, bcabhist, histChroma, histLRETI;
int vectorscopeScale;
int vectorscope[HistogramListener::vectorscope_size][HistogramListener::vectorscope_size];
/// Waveform's intensity. Same as height of reference image.
int waveformScale;
int waveformWidth;
@@ -202,6 +204,7 @@ protected:
void notifyHistogramChanged();
void reallocAll();
void updateLRGBHistograms();
void updateVectorscope();
void updateWaveforms();
void setScale(int prevscale);
void updatePreviewImage (int todo, bool panningRelatedChange);
@@ -560,8 +563,9 @@ public:
} denoiseInfoStore;
void updateHistogram() override;
void updateWaveform() override;
void requestUpdateHistogram() override;
void requestUpdateVectorscope() override;
void requestUpdateWaveform() override;
};
}

View File

@@ -308,6 +308,8 @@ class HistogramObservable;
class HistogramListener
{
public:
static constexpr int vectorscope_size = 128;
virtual ~HistogramListener() = default;
/** This member function is called when the histogram of the final image has changed.
* @param histRed is the array of size 256 containing the histogram of the red channel
@@ -330,6 +332,8 @@ public:
const LUTu& histBlueRaw,
const LUTu& histChroma,
const LUTu& histLRETI,
int vectorscopeScale,
const int vectorscope[vectorscope_size][vectorscope_size],
int waveformScale,
int waveformWidth,
const int waveformRed[][256],
@@ -340,17 +344,23 @@ public:
virtual void setObservable(HistogramObservable* observable) = 0;
/** Returns if the listener wants the histogram to be updated. */
virtual bool updateHistogram(void) = 0;
/** Returns if the listener wants the vectorscope to be updated. */
virtual bool updateVectorscope(void) = 0;
/** Returns if the listener wants the waveform to be updated. */
virtual bool updateWaveform(void) = 0;
/** Returns the vectorscope type: 0 for H-S and 1 for H-C. */
virtual int vectorscopeType(void) = 0;
};
class HistogramObservable
{
public:
/** Tells the observable to update the histogram data. */
virtual void updateHistogram() = 0;
virtual void requestUpdateHistogram() = 0;
/** Tells the observable to update the vectorscope data. */
virtual void requestUpdateVectorscope() = 0;
/** Tells the observable to update the waveform data. */
virtual void updateWaveform() = 0;
virtual void requestUpdateWaveform() = 0;
};
/** This listener is used when the auto exposure has been recomputed (e.g. when the clipping ratio changed). */